Skip to content

Commit

Permalink
Merge pull request #12 from Vishalk91-4/kcl-pretest
Browse files Browse the repository at this point in the history
Added assert, schema and remaining statement, test cases
  • Loading branch information
Peefy authored May 21, 2024
2 parents 51bd515 + 2126c35 commit 21babbc
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 1 deletion.
46 changes: 46 additions & 0 deletions test/corpus/assert.txt
Original file line number Diff line number Diff line change
@@ -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))))
22 changes: 22 additions & 0 deletions test/corpus/schema.txt
Original file line number Diff line number Diff line change
@@ -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))))))
63 changes: 62 additions & 1 deletion test/corpus/stmt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if True: a = 1
(integer)))))

================================================================================
if statement inline
if statement Basic
================================================================================

if True:
Expand All @@ -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))))))

0 comments on commit 21babbc

Please sign in to comment.