From 2126c35f67a884bbba2e2f1ed3565816192e4de5 Mon Sep 17 00:00:00 2001 From: Vishal Date: Sat, 18 May 2024 00:33:44 +0530 Subject: [PATCH] Added assert and schema test cases Signed-off-by: Vishal --- test/corpus/assert.txt | 46 ++++++++++++++++++++++++++++++ test/corpus/schema.txt | 22 +++++++++++++++ test/corpus/stmt.txt | 63 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 test/corpus/assert.txt create mode 100644 test/corpus/schema.txt diff --git a/test/corpus/assert.txt b/test/corpus/assert.txt new file mode 100644 index 0000000..ccd3138 --- /dev/null +++ b/test/corpus/assert.txt @@ -0,0 +1,46 @@ +================================================================================ +assert statements +================================================================================ + +assert x > 1 + +-------------------------------------------------------------------------------- + +(module + (assert_statement + (comparison_operator + (identifier) + (integer)))) + +================================================================================ +assert statements using if expression +================================================================================ + +assert a > 2 if a + +-------------------------------------------------------------------------------- + +(module + (assert_statement + (comparison_operator + (identifier) + (integer)) + (identifier))) + +================================================================================ +assert statements with error message +================================================================================ + +assert a == b, "SOS" + +-------------------------------------------------------------------------------- + +(module + (assert_statement + (comparison_operator + (identifier) + (identifier)) + (string + (string_start) + (string_content) + (string_end)))) \ No newline at end of file diff --git a/test/corpus/schema.txt b/test/corpus/schema.txt new file mode 100644 index 0000000..b009df0 --- /dev/null +++ b/test/corpus/schema.txt @@ -0,0 +1,22 @@ +================================================================================ +Schema Statement +================================================================================ + +schema Person: + firstName: str = "John" + +-------------------------------------------------------------------------------- + +(module + (schema_statement + (identifier) + (block + (assignment + (dotted_name + (identifier)) + (type + (basic_type)) + (string + (string_start) + (string_content) + (string_end)))))) \ No newline at end of file diff --git a/test/corpus/stmt.txt b/test/corpus/stmt.txt index a0c8d98..3e8ad6a 100644 --- a/test/corpus/stmt.txt +++ b/test/corpus/stmt.txt @@ -16,7 +16,7 @@ if True: a = 1 (integer))))) ================================================================================ -if statement inline +if statement Basic ================================================================================ if True: @@ -37,3 +37,64 @@ if True: (dotted_name (identifier)) (integer))))) + +================================================================================ +if statement with else +================================================================================ + +if True: + a = 1 +else: + b = 2 + +-------------------------------------------------------------------------------- + +(module + (if_statement + (true) + (block + (assignment + (dotted_name + (identifier)) + (integer))) + (else_clause + (block + (assignment + (dotted_name + (identifier)) + (integer)))))) + +================================================================================ +if statement with elif and else +================================================================================ + +if True: + a = 1 +elif False: + b = 2 +else: + c = 3 + +-------------------------------------------------------------------------------- + +(module + (if_statement + (true) + (block + (assignment + (dotted_name + (identifier)) + (integer))) + (elif_clause + (false) + (block + (assignment + (dotted_name + (identifier)) + (integer)))) + (else_clause + (block + (assignment + (dotted_name + (identifier)) + (integer)))))) \ No newline at end of file