1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 00:42:33 +03:00

Migrate javascript test cases over

This commit is contained in:
Timothy Clem 2017-02-23 09:55:30 -08:00
parent b80667f5b4
commit 6e9a2d24d9
385 changed files with 3354 additions and 0 deletions

View File

@ -23,7 +23,9 @@ spec :: Spec
spec = parallel $ do
it "lists example fixtures" $ do
examples "test/fixtures/ruby/" `shouldNotReturn` []
examples "test/fixtures/javascript/" `shouldNotReturn` []
describe "javascript" $ runTestsIn "test/fixtures/javascript/"
describe "ruby" $ runTestsIn "test/fixtures/ruby/"
where

View File

@ -0,0 +1 @@
function(a,b) { return a + b; }

View File

@ -0,0 +1 @@
function(b,c) { return b * c; }

View File

@ -0,0 +1,17 @@
(Program
(ExpressionStatements
(Function
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) }
(ExpressionStatements
(Return
{ (MathOperator
(Identifier)
(Other "+")
(Identifier))
->(MathOperator
(Identifier)
(Other "*")
(Identifier)) })))))

View File

@ -0,0 +1,17 @@
(Program
(ExpressionStatements
(Function
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) }
(ExpressionStatements
(Return
{ (MathOperator
(Identifier)
(Other "*")
(Identifier))
->(MathOperator
(Identifier)
(Other "+")
(Identifier)) })))))

View File

@ -0,0 +1,11 @@
(Program
(ExpressionStatements
(Function
(Identifier)
(Identifier)
(ExpressionStatements
(Return
(MathOperator
(Identifier)
(Other "+")
(Identifier)))))))

View File

@ -0,0 +1,11 @@
(Program
(ExpressionStatements
(Function
(Identifier)
(Identifier)
(ExpressionStatements
(Return
(MathOperator
(Identifier)
(Other "*")
(Identifier)))))))

View File

@ -0,0 +1 @@
function() { return 'hi'; }

View File

@ -0,0 +1 @@
function() { return 'hello'; }

View File

@ -0,0 +1,7 @@
(Program
(ExpressionStatements
(Function
(ExpressionStatements
(Return
{ (StringLiteral)
->(StringLiteral) })))))

View File

@ -0,0 +1,7 @@
(Program
(ExpressionStatements
(Function
(ExpressionStatements
(Return
{ (StringLiteral)
->(StringLiteral) })))))

View File

@ -0,0 +1,6 @@
(Program
(ExpressionStatements
(Function
(ExpressionStatements
(Return
(StringLiteral))))))

View File

@ -0,0 +1,6 @@
(Program
(ExpressionStatements
(Function
(ExpressionStatements
(Return
(StringLiteral))))))

1
test/fixtures/javascript/array.A.js vendored Normal file
View File

@ -0,0 +1 @@
[ "item1" ];

1
test/fixtures/javascript/array.B.js vendored Normal file
View File

@ -0,0 +1 @@
[ "item1", "item2" ];

View File

@ -0,0 +1,5 @@
(Program
(ExpressionStatements
(ArrayLiteral
(StringLiteral)
{+(StringLiteral)+})))

View File

@ -0,0 +1,5 @@
(Program
(ExpressionStatements
(ArrayLiteral
(StringLiteral)
{-(StringLiteral)-})))

View File

@ -0,0 +1,4 @@
(Program
(ExpressionStatements
(ArrayLiteral
(StringLiteral))))

View File

@ -0,0 +1,5 @@
(Program
(ExpressionStatements
(ArrayLiteral
(StringLiteral)
(StringLiteral))))

View File

@ -0,0 +1 @@
(f, g) => { return h; };

View File

@ -0,0 +1 @@
(f, g) => { return g; };

View File

@ -0,0 +1,9 @@
(Program
(ExpressionStatements
(Function
(Identifier)
(Identifier)
(ExpressionStatements
(Return
{ (Identifier)
->(Identifier) })))))

View File

@ -0,0 +1,9 @@
(Program
(ExpressionStatements
(Function
(Identifier)
(Identifier)
(ExpressionStatements
(Return
{ (Identifier)
->(Identifier) })))))

View File

@ -0,0 +1,8 @@
(Program
(ExpressionStatements
(Function
(Identifier)
(Identifier)
(ExpressionStatements
(Return
(Identifier))))))

View File

@ -0,0 +1,8 @@
(Program
(ExpressionStatements
(Function
(Identifier)
(Identifier)
(ExpressionStatements
(Return
(Identifier))))))

View File

@ -0,0 +1 @@
x = 0;

View File

@ -0,0 +1 @@
x = 1;

View File

@ -0,0 +1,6 @@
(Program
(ExpressionStatements
(Assignment
(Identifier)
{ (NumberLiteral)
->(NumberLiteral) })))

View File

@ -0,0 +1,6 @@
(Program
(ExpressionStatements
(Assignment
(Identifier)
{ (NumberLiteral)
->(NumberLiteral) })))

View File

@ -0,0 +1,5 @@
(Program
(ExpressionStatements
(Assignment
(Identifier)
(NumberLiteral))))

View File

@ -0,0 +1,5 @@
(Program
(ExpressionStatements
(Assignment
(Identifier)
(NumberLiteral))))

View File

@ -0,0 +1 @@
i >> j;

View File

@ -0,0 +1 @@
i >> k;

View File

@ -0,0 +1,7 @@
(Program
(ExpressionStatements
(BitwiseOperator
(Identifier)
(Other ">>")
{ (Identifier)
->(Identifier) })))

View File

@ -0,0 +1,7 @@
(Program
(ExpressionStatements
(BitwiseOperator
(Identifier)
(Other ">>")
{ (Identifier)
->(Identifier) })))

View File

@ -0,0 +1,6 @@
(Program
(ExpressionStatements
(BitwiseOperator
(Identifier)
(Other ">>")
(Identifier))))

View File

@ -0,0 +1,6 @@
(Program
(ExpressionStatements
(BitwiseOperator
(Identifier)
(Other ">>")
(Identifier))))

View File

@ -0,0 +1 @@
i || j;

View File

@ -0,0 +1 @@
i && j;

View File

@ -0,0 +1,10 @@
(Program
(ExpressionStatements
{ (BooleanOperator
(Identifier)
(Other "||")
(Identifier))
->(BooleanOperator
(Identifier)
(Other "&&")
(Identifier)) }))

View File

@ -0,0 +1,10 @@
(Program
(ExpressionStatements
{ (BooleanOperator
(Identifier)
(Other "&&")
(Identifier))
->(BooleanOperator
(Identifier)
(Other "||")
(Identifier)) }))

View File

@ -0,0 +1,6 @@
(Program
(ExpressionStatements
(BooleanOperator
(Identifier)
(Other "||")
(Identifier))))

View File

@ -0,0 +1,6 @@
(Program
(ExpressionStatements
(BooleanOperator
(Identifier)
(Other "&&")
(Identifier))))

1
test/fixtures/javascript/break.A.js vendored Normal file
View File

@ -0,0 +1 @@
for (i = 0; i < 10; i++) { if (i === 4) { break; }; i }

1
test/fixtures/javascript/break.B.js vendored Normal file
View File

@ -0,0 +1 @@
for (i = 0; i < 10; i++) { if (i === 4) { continue; }; i }

View File

@ -0,0 +1,23 @@
(Program
(For
(Assignment
(Identifier)
(NumberLiteral))
(RelationalOperator
(Identifier)
(Other "<")
(NumberLiteral))
(MathOperator
(Identifier)
(Other "++"))
(ExpressionStatements
(If
(RelationalOperator
(Identifier)
(Other "===")
(NumberLiteral))
(ExpressionStatements
{+(Continue)+}
{-(Break)-}))
(ExpressionStatements
(Identifier)))))

View File

@ -0,0 +1,23 @@
(Program
(For
(Assignment
(Identifier)
(NumberLiteral))
(RelationalOperator
(Identifier)
(Other "<")
(NumberLiteral))
(MathOperator
(Identifier)
(Other "++"))
(ExpressionStatements
(If
(RelationalOperator
(Identifier)
(Other "===")
(NumberLiteral))
(ExpressionStatements
{+(Break)+}
{-(Continue)-}))
(ExpressionStatements
(Identifier)))))

View File

@ -0,0 +1,22 @@
(Program
(For
(Assignment
(Identifier)
(NumberLiteral))
(RelationalOperator
(Identifier)
(Other "<")
(NumberLiteral))
(MathOperator
(Identifier)
(Other "++"))
(ExpressionStatements
(If
(RelationalOperator
(Identifier)
(Other "===")
(NumberLiteral))
(ExpressionStatements
(Break)))
(ExpressionStatements
(Identifier)))))

View File

@ -0,0 +1,22 @@
(Program
(For
(Assignment
(Identifier)
(NumberLiteral))
(RelationalOperator
(Identifier)
(Other "<")
(NumberLiteral))
(MathOperator
(Identifier)
(Other "++"))
(ExpressionStatements
(If
(RelationalOperator
(Identifier)
(Other "===")
(NumberLiteral))
(ExpressionStatements
(Continue)))
(ExpressionStatements
(Identifier)))))

View File

@ -0,0 +1 @@
this.map(function (a) { return a.b; })

View File

@ -0,0 +1 @@
this.reduce(function (a) { return b.a; })

View File

@ -0,0 +1,15 @@
(Program
(ExpressionStatements
(FunctionCall
(Identifier)
{ (Identifier)
->(Identifier) }
(Function
(Identifier)
(ExpressionStatements
(Return
(MemberAccess
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) })))))))

View File

@ -0,0 +1,15 @@
(Program
(ExpressionStatements
(FunctionCall
(Identifier)
{ (Identifier)
->(Identifier) }
(Function
(Identifier)
(ExpressionStatements
(Return
(MemberAccess
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) })))))))

View File

@ -0,0 +1,12 @@
(Program
(ExpressionStatements
(FunctionCall
(Identifier)
(Identifier)
(Function
(Identifier)
(ExpressionStatements
(Return
(MemberAccess
(Identifier)
(Identifier))))))))

View File

@ -0,0 +1,12 @@
(Program
(ExpressionStatements
(FunctionCall
(Identifier)
(Identifier)
(Function
(Identifier)
(ExpressionStatements
(Return
(MemberAccess
(Identifier)
(Identifier))))))))

View File

@ -0,0 +1 @@
return returned.promise().done( newDefer.resolve ).fail( newDefer.reject )

View File

@ -0,0 +1 @@
return returned.promise().done( otherDefer.resolve ).fail( otherDefer.reject )

View File

@ -0,0 +1,17 @@
(Program
(Return
(FunctionCall
(FunctionCall
(FunctionCall
(Identifier)
(Identifier))
(Identifier)
(MemberAccess
{ (Identifier)
->(Identifier) }
(Identifier)))
(Identifier)
(MemberAccess
{ (Identifier)
->(Identifier) }
(Identifier)))))

View File

@ -0,0 +1,17 @@
(Program
(Return
(FunctionCall
(FunctionCall
(FunctionCall
(Identifier)
(Identifier))
(Identifier)
(MemberAccess
{ (Identifier)
->(Identifier) }
(Identifier)))
(Identifier)
(MemberAccess
{ (Identifier)
->(Identifier) }
(Identifier)))))

View File

@ -0,0 +1,15 @@
(Program
(Return
(FunctionCall
(FunctionCall
(FunctionCall
(Identifier)
(Identifier))
(Identifier)
(MemberAccess
(Identifier)
(Identifier)))
(Identifier)
(MemberAccess
(Identifier)
(Identifier)))))

View File

@ -0,0 +1,15 @@
(Program
(Return
(FunctionCall
(FunctionCall
(FunctionCall
(Identifier)
(Identifier))
(Identifier)
(MemberAccess
(Identifier)
(Identifier)))
(Identifier)
(MemberAccess
(Identifier)
(Identifier)))))

1
test/fixtures/javascript/class.A.js vendored Normal file
View File

@ -0,0 +1 @@
class Foo { static one(a) { return a; }; two(b) { return b; } three(c) { return c; } }

1
test/fixtures/javascript/class.B.js vendored Normal file
View File

@ -0,0 +1 @@
class Foo { static foo(a) { return a; }; bar(b) { return b; } baz(c) { return c; } }

View File

@ -0,0 +1,22 @@
(Program
(ExpressionStatements
(Class
(Identifier)
(Method
{ (Identifier)
->(Identifier) }
(Identifier)
(Return
(Identifier)))
(Method
{ (Identifier)
->(Identifier) }
(Identifier)
(Return
(Identifier)))
(Method
{ (Identifier)
->(Identifier) }
(Identifier)
(Return
(Identifier))))))

View File

@ -0,0 +1,22 @@
(Program
(ExpressionStatements
(Class
(Identifier)
(Method
{ (Identifier)
->(Identifier) }
(Identifier)
(Return
(Identifier)))
(Method
{ (Identifier)
->(Identifier) }
(Identifier)
(Return
(Identifier)))
(Method
{ (Identifier)
->(Identifier) }
(Identifier)
(Return
(Identifier))))))

View File

@ -0,0 +1,19 @@
(Program
(ExpressionStatements
(Class
(Identifier)
(Method
(Identifier)
(Identifier)
(Return
(Identifier)))
(Method
(Identifier)
(Identifier)
(Return
(Identifier)))
(Method
(Identifier)
(Identifier)
(Return
(Identifier))))))

View File

@ -0,0 +1,19 @@
(Program
(ExpressionStatements
(Class
(Identifier)
(Method
(Identifier)
(Identifier)
(Return
(Identifier)))
(Method
(Identifier)
(Identifier)
(Return
(Identifier)))
(Method
(Identifier)
(Identifier)
(Return
(Identifier))))))

View File

@ -0,0 +1 @@
a = 1, b = 2;

View File

@ -0,0 +1 @@
c = {d: (3, 4 + 5, 6)};

View File

@ -0,0 +1,21 @@
(Program
(ExpressionStatements
{+(Assignment
(Identifier)
(Object
(Pair
(Identifier)
(CommaOperator
(NumberLiteral)
(MathOperator
(NumberLiteral)
(Other "+")
(NumberLiteral))
(NumberLiteral)))))+}
{-(CommaOperator
(Assignment
(Identifier)
(NumberLiteral))
(Assignment
(Identifier)
(NumberLiteral)))-}))

View File

@ -0,0 +1,21 @@
(Program
(ExpressionStatements
{+(CommaOperator
(Assignment
(Identifier)
(NumberLiteral))
(Assignment
(Identifier)
(NumberLiteral)))+}
{-(Assignment
(Identifier)
(Object
(Pair
(Identifier)
(CommaOperator
(NumberLiteral)
(MathOperator
(NumberLiteral)
(Other "+")
(NumberLiteral))
(NumberLiteral)))))-}))

View File

@ -0,0 +1,9 @@
(Program
(ExpressionStatements
(CommaOperator
(Assignment
(Identifier)
(NumberLiteral))
(Assignment
(Identifier)
(NumberLiteral)))))

View File

@ -0,0 +1,14 @@
(Program
(ExpressionStatements
(Assignment
(Identifier)
(Object
(Pair
(Identifier)
(CommaOperator
(NumberLiteral)
(MathOperator
(NumberLiteral)
(Other "+")
(NumberLiteral))
(NumberLiteral)))))))

1
test/fixtures/javascript/comment.A.js vendored Normal file
View File

@ -0,0 +1 @@
// This is a property

3
test/fixtures/javascript/comment.B.js vendored Normal file
View File

@ -0,0 +1,3 @@
/*
* This is a method
*/

View File

@ -0,0 +1,3 @@
(Program
{ (Comment)
->(Comment) })

View File

@ -0,0 +1,3 @@
(Program
{ (Comment)
->(Comment) })

View File

@ -0,0 +1,2 @@
(Program
(Comment))

View File

@ -0,0 +1,2 @@
(Program
(Comment))

View File

@ -0,0 +1 @@
new module.Klass(1, "two");

View File

@ -0,0 +1 @@
new module.Klass(1, "three");

View File

@ -0,0 +1,9 @@
(Program
(ExpressionStatements
(Constructor
(FunctionCall
(Identifier)
(Identifier)
(NumberLiteral)
{ (StringLiteral)
->(StringLiteral) }))))

View File

@ -0,0 +1,9 @@
(Program
(ExpressionStatements
(Constructor
(FunctionCall
(Identifier)
(Identifier)
(NumberLiteral)
{ (StringLiteral)
->(StringLiteral) }))))

View File

@ -0,0 +1,8 @@
(Program
(ExpressionStatements
(Constructor
(FunctionCall
(Identifier)
(Identifier)
(NumberLiteral)
(StringLiteral)))))

View File

@ -0,0 +1,8 @@
(Program
(ExpressionStatements
(Constructor
(FunctionCall
(Identifier)
(Identifier)
(NumberLiteral)
(StringLiteral)))))

View File

@ -0,0 +1 @@
for (i = 0; i < 10; i++) { if (i === 4) { continue; }; i }

View File

@ -0,0 +1 @@
for (i = 0; i < 10; i++) { if (i === 4) { break; }; i }

View File

@ -0,0 +1,23 @@
(Program
(For
(Assignment
(Identifier)
(NumberLiteral))
(RelationalOperator
(Identifier)
(Other "<")
(NumberLiteral))
(MathOperator
(Identifier)
(Other "++"))
(ExpressionStatements
(If
(RelationalOperator
(Identifier)
(Other "===")
(NumberLiteral))
(ExpressionStatements
{+(Break)+}
{-(Continue)-}))
(ExpressionStatements
(Identifier)))))

View File

@ -0,0 +1,23 @@
(Program
(For
(Assignment
(Identifier)
(NumberLiteral))
(RelationalOperator
(Identifier)
(Other "<")
(NumberLiteral))
(MathOperator
(Identifier)
(Other "++"))
(ExpressionStatements
(If
(RelationalOperator
(Identifier)
(Other "===")
(NumberLiteral))
(ExpressionStatements
{+(Continue)+}
{-(Break)-}))
(ExpressionStatements
(Identifier)))))

View File

@ -0,0 +1,22 @@
(Program
(For
(Assignment
(Identifier)
(NumberLiteral))
(RelationalOperator
(Identifier)
(Other "<")
(NumberLiteral))
(MathOperator
(Identifier)
(Other "++"))
(ExpressionStatements
(If
(RelationalOperator
(Identifier)
(Other "===")
(NumberLiteral))
(ExpressionStatements
(Continue)))
(ExpressionStatements
(Identifier)))))

View File

@ -0,0 +1,22 @@
(Program
(For
(Assignment
(Identifier)
(NumberLiteral))
(RelationalOperator
(Identifier)
(Other "<")
(NumberLiteral))
(MathOperator
(Identifier)
(Other "++"))
(ExpressionStatements
(If
(RelationalOperator
(Identifier)
(Other "===")
(NumberLiteral))
(ExpressionStatements
(Break)))
(ExpressionStatements
(Identifier)))))

View File

@ -0,0 +1 @@
delete thing['prop'];

View File

@ -0,0 +1 @@
delete thing.prop

View File

@ -0,0 +1,12 @@
(Program
(ExpressionStatements
{ (Operator
(Other "delete")
(SubscriptAccess
(Identifier)
(StringLiteral)))
->(Operator
(Other "delete")
(MemberAccess
(Identifier)
(Identifier))) }))

View File

@ -0,0 +1,12 @@
(Program
(ExpressionStatements
{ (Operator
(Other "delete")
(MemberAccess
(Identifier)
(Identifier)))
->(Operator
(Other "delete")
(SubscriptAccess
(Identifier)
(StringLiteral))) }))

View File

@ -0,0 +1,7 @@
(Program
(ExpressionStatements
(Operator
(Other "delete")
(SubscriptAccess
(Identifier)
(StringLiteral)))))

View File

@ -0,0 +1,7 @@
(Program
(ExpressionStatements
(Operator
(Other "delete")
(MemberAccess
(Identifier)
(Identifier)))))

View File

@ -0,0 +1 @@
do { console.log(insert); } while (true);

View File

@ -0,0 +1 @@
do { console.log(replacement); } while (false);

View File

@ -0,0 +1,11 @@
(Program
(DoWhile
(ExpressionStatements
(ExpressionStatements
(FunctionCall
(Identifier)
(Identifier)
{ (Identifier)
->(Identifier) })))
{ (Boolean)
->(Boolean) }))

Some files were not shown because too many files have changed in this diff Show More