Skip to content

Commit

Permalink
chore: add new regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Jan 31, 2024
1 parent 3003ef7 commit c7be60f
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 7 deletions.
14 changes: 12 additions & 2 deletions test/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ class Foo extends require('another-class') {
}
}

class A{;}

---

(program
Expand Down Expand Up @@ -628,7 +630,10 @@ class Foo extends require('another-class') {
(member_expression
(super)
(property_identifier))
(arguments))))))))
(arguments)))))))
(class_declaration
(identifier)
(class_body)))

============================================
Classes with reserved words as methods
Expand Down Expand Up @@ -1325,6 +1330,7 @@ i + j * 3 - j % 5;
2 ** i ** 3;
+x;
-x;
let + 5;

---

Expand Down Expand Up @@ -1368,7 +1374,11 @@ i + j * 3 - j % 5;
(identifier)))
(expression_statement
(unary_expression
(identifier))))
(identifier)))
(expression_statement
(binary_expression
(identifier)
(number))))

============================================
Boolean operators
Expand Down
77 changes: 72 additions & 5 deletions test/corpus/statements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ import { member1 , member2 as alias2, } from "module-name";
import("a");
import("a").then((m) => {});
import.meta.url;
import { b } from
'b'; /* comment */ import
{ a } from 'a';

----

Expand Down Expand Up @@ -179,7 +182,22 @@ import.meta.url;
(member_expression
(import)
(property_identifier))
(property_identifier))))
(property_identifier)))
(import_statement
(import_clause
(named_imports
(import_specifier
(identifier))))
(string
(string_fragment)))
(comment)
(import_statement
(import_clause
(named_imports
(import_specifier
(identifier))))
(string
(string_fragment))))

============================================
Exports
Expand Down Expand Up @@ -364,6 +382,8 @@ if (a.b) {
d;
}

if (n-->0){}

----

(program
Expand All @@ -387,7 +407,14 @@ if (a.b) {
arguments: (arguments
(identifier))))
(expression_statement
(identifier)))))
(identifier))))
(if_statement
condition: (parenthesized_expression
(binary_expression
left: (update_expression
argument: (identifier))
right: (number)))
consequence: (statement_block)))

============================================
If-else statements
Expand Down Expand Up @@ -452,6 +479,8 @@ for (var i = 0
; i++) {
}

for (let in {});

---

(program
Expand Down Expand Up @@ -504,7 +533,11 @@ for (var i = 0
right: (identifier)))
increment: (update_expression
argument: (identifier))
body: (statement_block)))
body: (statement_block))
(for_in_statement
left: (identifier)
right: (object)
body: (empty_statement)))

============================================
For-in statements
Expand Down Expand Up @@ -859,6 +892,10 @@ var thing = {
}
};

let foo = bar
// this is a comment
? 'baz' : 'thud';

---

(program
Expand Down Expand Up @@ -886,7 +923,17 @@ var thing = {
(expression_statement
(call_expression
(identifier)
(arguments))))))))))
(arguments)))))))))
(lexical_declaration
(variable_declarator
(identifier)
(ternary_expression
(identifier)
(comment)
(string
(string_fragment))
(string
(string_fragment))))))

============================================
Comments with asterisks
Expand All @@ -906,6 +953,14 @@ const c = 1;
***/
const d = 1;

class E {
f() {
} /*** com
ment ***/
g() {
}
}

---

(program
Expand All @@ -928,7 +983,19 @@ const d = 1;
(lexical_declaration
(variable_declarator
(identifier)
(number))))
(number)))
(class_declaration
(identifier)
(class_body
(method_definition
(property_identifier)
(formal_parameters)
(statement_block))
(comment)
(method_definition
(property_identifier)
(formal_parameters)
(statement_block)))))

==========================================
Comments within expressions
Expand Down

0 comments on commit c7be60f

Please sign in to comment.