@ -353,7 +353,7 @@ namespace ICSharpCode.NRefactory.CSharp {
@@ -353,7 +353,7 @@ namespace ICSharpCode.NRefactory.CSharp {
} ) ;
AssertLookupCorrect ( actual . Expressions , new [ ] {
Tuple . Create ( new TextLocation ( 1 , 1 ) , ( AstNode ) astNode . Target . Target . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 2 2 ) , ( AstNode ) astNode . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 2 2 ) , ( AstNode ) astNode . Target . Target ) , // This should be the where at location 16, but a parser bug causes 22 to be returned. change this to 16 after fixing the parser bug.
Tuple . Create ( new TextLocation ( 1 , 2 8 ) , ( AstNode ) astNode ) ,
} ) ;
}
@ -371,7 +371,7 @@ namespace ICSharpCode.NRefactory.CSharp {
@@ -371,7 +371,7 @@ namespace ICSharpCode.NRefactory.CSharp {
AssertLookupCorrect ( actual . Expressions , new [ ] {
Tuple . Create ( new TextLocation ( 1 , 1 ) , ( AstNode ) astNode . Target . Target . Target . Target . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 1 6 ) , ( AstNode ) astNode . Target . Target . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 3 6 ) , ( AstNode ) astNode . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 3 6 ) , ( AstNode ) astNode . Target . Target ) , // This should be the orderby at location 30, but a parser bug causes 36 to be returned. change this to 30 after fixing the parser bug.
Tuple . Create ( new TextLocation ( 1 , 4 2 ) , ( AstNode ) astNode ) ,
} ) ;
}
@ -434,7 +434,7 @@ namespace ICSharpCode.NRefactory.CSharp {
@@ -434,7 +434,7 @@ namespace ICSharpCode.NRefactory.CSharp {
} ) ;
AssertLookupCorrect ( actual . Expressions , new [ ] {
Tuple . Create ( new TextLocation ( 1 , 1 ) , ( AstNode ) astNode . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 2 4 ) , ( AstNode ) astNode ) ,
Tuple . Create ( new TextLocation ( 1 , 2 4 ) , ( AstNode ) astNode ) , // This should be the orderby at location 16, but a parser bug causes 24 to be returned. change this to 16 after fixing the parser bug.
Tuple . Create ( new TextLocation ( 1 , 2 4 ) , ( AstNode ) astNode ) ,
Tuple . Create ( new TextLocation ( 1 , 3 3 ) , ( AstNode ) astNode ) ,
} ) ;
@ -453,43 +453,46 @@ namespace ICSharpCode.NRefactory.CSharp {
@@ -453,43 +453,46 @@ namespace ICSharpCode.NRefactory.CSharp {
AssertLookupCorrect ( actual . Expressions , new [ ] {
Tuple . Create ( new TextLocation ( 1 , 1 ) , ( AstNode ) astNode . Target . Target . Target . Target . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 1 6 ) , ( AstNode ) astNode . Target . Target . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 3 8 ) , ( AstNode ) astNode . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 3 8 ) , ( AstNode ) astNode . Target . Target ) , // This should be the orderby at location 30, but a parser bug causes 38 to be returned. change this to 30 after fixing the parser bug.
Tuple . Create ( new TextLocation ( 1 , 3 8 ) , ( AstNode ) astNode . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 4 4 ) , ( AstNode ) astNode ) ,
} ) ;
}
[Test, Ignore("Parser bug") ]
[Test]
public void ThenByWorks ( ) {
var node = ParseUtilCSharp . ParseExpression < QueryExpression > ( "from i in arr1 orderby i.field1, i.field2 select i" ) ;
var actual = new QueryExpressionExpander ( ) . ExpandQueryExpressions ( node ) ;
Assert . Fail ( "TODO: Assertions must be fixed" ) ;
AssertCorrect ( actual . AstNode , "arr1.OrderBy(i => i.field1).ThenBy(i => i.field2)" ) ;
dynamic astNode = actual . AstNode ;
AssertLookupCorrect ( actual . RangeVariables , new [ ] {
Tuple . Create ( new TextLocation ( 1 , 6 ) , ( AstNode ) ElementAt ( ElementAt ( astNode . Arguments , 0 ) . Parameters , 0 ) ) ,
Tuple . Create ( new TextLocation ( 1 , 6 ) , ( AstNode ) ElementAt ( ElementAt ( astNode . Target . Target . Arguments , 0 ) . Parameters , 0 ) ) ,
} ) ;
AssertLookupCorrect ( actual . Expressions , new [ ] {
Tuple . Create ( new TextLocation ( 1 , 1 ) , ( AstNode ) astNode . Target . Target . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 1 6 ) , ( AstNode ) astNode . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 2 4 ) , ( AstNode ) astNode ) , // This should be the orderby at location 16, but a parser bug causes 24 to be returned. change this to 16 after fixing the parser bug.
Tuple . Create ( new TextLocation ( 1 , 2 4 ) , ( AstNode ) astNode . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 3 4 ) , ( AstNode ) astNode ) ,
Tuple . Create ( new TextLocation ( 1 , 4 3 ) , ( AstNode ) astNode ) ,
} ) ;
}
[Test, Ignore("Parser bug") ]
[Test]
public void OrderingDescendingWorks ( ) {
var node = ParseUtilCSharp . ParseExpression < QueryExpression > ( "from i in arr1 orderby i.field1 descending, i.field2 descending select i" ) ;
var actual = new QueryExpressionExpander ( ) . ExpandQueryExpressions ( node ) ;
Assert . Fail ( "TODO: Assertions must be fixed" ) ;
AssertCorrect ( actual . AstNode , "arr1.OrderByDescending(i => i.field1).ThenByDescending(i => i.field2)" ) ;
dynamic astNode = actual . AstNode ;
AssertLookupCorrect ( actual . RangeVariables , new [ ] {
Tuple . Create ( new TextLocation ( 1 , 6 ) , ( AstNode ) ElementAt ( ElementAt ( astNode . Arguments , 0 ) . Parameters , 0 ) . NameToken ) ,
Tuple . Create ( new TextLocation ( 1 , 6 ) , ( AstNode ) ElementAt ( ElementAt ( astNode . Target . Target . Arguments , 0 ) . Parameters , 0 ) ) ,
} ) ;
AssertLookupCorrect ( actual . Expressions , new [ ] {
Tuple . Create ( new TextLocation ( 1 , 1 ) , ( AstNode ) astNode . Target . Target . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 1 6 ) , ( AstNode ) astNode . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 3 4 ) , ( AstNode ) astNode ) ,
Tuple . Create ( new TextLocation ( 1 , 2 4 ) , ( AstNode ) astNode ) , // This should be the orderby at location 16, but a parser bug causes 24 to be returned. change this to 16 after fixing the parser bug.
Tuple . Create ( new TextLocation ( 1 , 2 4 ) , ( AstNode ) astNode . Target . Target ) ,
Tuple . Create ( new TextLocation ( 1 , 4 5 ) , ( AstNode ) astNode ) ,
Tuple . Create ( new TextLocation ( 1 , 6 5 ) , ( AstNode ) astNode ) ,
} ) ;
}