mirror of
https://github.com/lloeki/wasp.git
synced 2025-12-06 10:44:39 +01:00
let's get more serious (splat that mess)
This commit is contained in:
parent
91020ddfe6
commit
e8a036bb16
7 changed files with 132 additions and 96 deletions
39
test.py
Normal file
39
test.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
from unittest import TestCase
|
||||
import wasp.parser as parser
|
||||
|
||||
class TestParser(TestCase):
|
||||
def test_atom(self):
|
||||
self.assertEqual(str(parser.parse("1")), "1")
|
||||
|
||||
def test_quoted_atom(self):
|
||||
self.assertEqual(str(parser.parse("'1")), "'1")
|
||||
|
||||
def test_nonalpha_symbol(self):
|
||||
self.assertEqual(str(parser.parse("+")), "+")
|
||||
|
||||
def test_quoted_nonalpha_symbol(self):
|
||||
self.assertEqual(str(parser.parse("'+")), "'+")
|
||||
|
||||
def test_list(self):
|
||||
self.assertEqual(str(parser.parse("(+ 1 2)")),
|
||||
"(+ . (1 . (2 . NIL)))")
|
||||
|
||||
def test_quoted_list(self):
|
||||
self.assertEqual(str(parser.parse("'(+ 1 2)")),
|
||||
"'(+ . (1 . (2 . NIL)))")
|
||||
|
||||
def test_list_in_list(self):
|
||||
self.assertEqual(str(parser.parse("(+ 1 (* 3 2))")),
|
||||
"(+ . (1 . ((* . (3 . (2 . NIL))) . NIL)))")
|
||||
|
||||
def test_lists_in_list(self):
|
||||
self.assertEqual(str(parser.parse("(+ (* 4 5) (* 3 2))")),
|
||||
"(+ . ((* . (4 . (5 . NIL))) . ((* . (3 . (2 . NIL))) . NIL)))")
|
||||
|
||||
def test_quote_in_list(self):
|
||||
self.assertEqual(str(parser.parse("(+ '1 (* 3 2))")),
|
||||
"(+ . ('1 . ((* . (3 . (2 . NIL))) . NIL)))")
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue