예제 #1
0
 def testGetFormsLambdaList2(self):
     st = """def foo(a,) {}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms,
                      [(FORM_TYPE, [(ATOM_TYPE, "defun"),
                                    (ATOM_TYPE, "foo"),
                                    (FORM_TYPE, [(ATOM_TYPE, "a")])])])
예제 #2
0
 def testGetFormsClass1(self):
     st = """class foo {}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms, [(FORM_TYPE, [(ATOM_TYPE, "defclass"),
                                           (ATOM_TYPE, "foo"),
                                           (FORM_TYPE, []),
                                           (FORM_TYPE, [])])])
예제 #3
0
 def testGetFormsBodyBlock5(self):
     st = """x=foo{}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo(), True)
     self.assertEqual(forms,
                      [(COMMENT_TYPE, "; source line # 1"),
                       (FORM_TYPE, [(ATOM_TYPE, "setf"), (ATOM_TYPE, "x"),
                                    (FORM_TYPE, [(ATOM_TYPE, "foo")])])])
예제 #4
0
 def testGetFormsImplicitLexscope9(self):
     st = """progn{
                 foo(x)
                 x=0
                 lexscope explicit
                 global z
                 z=1
                 lexscope implicit
                 y=2
                 foo(x)}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)),
                      LevelInfo(implScope=True, explScopeWarn=True))
     self.assertEqual(forms, [(FORM_TYPE, [
         (ATOM_TYPE, "progn"),
         (FORM_TYPE, [(ATOM_TYPE, "foo"), (ATOM_TYPE, "x")]),
         (FORM_TYPE, [(ATOM_TYPE, "let"), (FORM_TYPE, [(ATOM_TYPE, "x")]),
                      (FORM_TYPE, [(ATOM_TYPE, "setf"), (ATOM_TYPE, "x"),
                                   (ATOM_TYPE, "0")]),
                      (FORM_TYPE, [(ATOM_TYPE, "setf"), (ATOM_TYPE, "z"),
                                   (ATOM_TYPE, "1")]),
                      (FORM_TYPE, [(ATOM_TYPE, "let"),
                                   (FORM_TYPE, [(ATOM_TYPE, "y")]),
                                   (FORM_TYPE, [(ATOM_TYPE, "setf"),
                                                (ATOM_TYPE, "y"),
                                                (ATOM_TYPE, "2")]),
                                   (FORM_TYPE, [(ATOM_TYPE, "foo"),
                                                (ATOM_TYPE, "x")])])])
     ])])
예제 #5
0
 def testGetFormsFletAndReturn1(self):
     st = """flet foo {return}
                  boo (a) {return a}
                  pr (b) {return}
                  {foo(1,2)-boo(3,4)}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms, [(FORM_TYPE, [
         (ATOM_TYPE, "flet"),
         (FORM_TYPE, [(FORM_TYPE, [(ATOM_TYPE, "foo"), (FORM_TYPE, []),
                                   (FORM_TYPE, [(ATOM_TYPE, "return-from"),
                                                (ATOM_TYPE, "foo"),
                                                (FORM_TYPE, [])])]),
                      (FORM_TYPE, [(ATOM_TYPE, "boo"),
                                   (FORM_TYPE, [(ATOM_TYPE, "a")]),
                                   (FORM_TYPE, [(ATOM_TYPE, "return-from"),
                                                (ATOM_TYPE, "boo"),
                                                (ATOM_TYPE, "a")])]),
                      (FORM_TYPE, [(ATOM_TYPE, "pr"),
                                   (FORM_TYPE, [(ATOM_TYPE, "b")]),
                                   (FORM_TYPE, [(ATOM_TYPE, "return-from"),
                                                (ATOM_TYPE, "pr"),
                                                (FORM_TYPE, [])])])]),
         (FORM_TYPE, [(ATOM_TYPE, "_-_"),
                      (FORM_TYPE, [(ATOM_TYPE, "foo"), (ATOM_TYPE, "1"),
                                   (ATOM_TYPE, "2")]),
                      (FORM_TYPE, [(ATOM_TYPE, "boo"), (ATOM_TYPE, "3"),
                                   (ATOM_TYPE, "4")])])
     ])])
예제 #6
0
 def testGetFormsObjMeth3(self):
     st = """x=y.foo()"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms,
                      [(FORM_TYPE, [(ATOM_TYPE, "setf"), (ATOM_TYPE, "x"),
                                    (FORM_TYPE, [(ATOM_TYPE, "foo"),
                                                 (ATOM_TYPE, "y")])])])
예제 #7
0
 def testGetFormsColumn7(self):
     st = """x='foo:a"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms, [(FORM_TYPE, [(ATOM_TYPE, "setf"),
                                           (ATOM_TYPE, "x"),
                                           (SHORTCUT_TYPE, "'",
                                            (ATOM_TYPE, "foo:a"))])])
예제 #8
0
 def testGetFormsBlockForm8(self):
     st = """def $foo {}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms, [(FORM_TYPE, [(ATOM_TYPE, "defun"),
                                           (SHORTCUT_TYPE, ",",
                                            (ATOM_TYPE, "foo")),
                                           (FORM_TYPE, [])])])
예제 #9
0
 def testGetFormsOperForm8(self):
     st = """x+'y"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms, [(FORM_TYPE, [(ATOM_TYPE, "_+_"),
                                           (ATOM_TYPE, "x"),
                                           (SHORTCUT_TYPE, "'",
                                            (ATOM_TYPE, "y"))])])
예제 #10
0
 def testGetFormsMeth1(self):
     st = """meth foo (a){}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms,
                      [(FORM_TYPE, [(ATOM_TYPE, "defmethod"),
                                    (ATOM_TYPE, "foo"),
                                    (FORM_TYPE, [(ATOM_TYPE, "a")])])])
예제 #11
0
 def testGetFormsBlockName4(self):
     st = """block $foo {a}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms, [(FORM_TYPE, [(ATOM_TYPE, "block"),
                                           (SHORTCUT_TYPE, ",",
                                            (ATOM_TYPE, "foo")),
                                           (ATOM_TYPE, "a")])])
예제 #12
0
 def testGetFormsDoLists2(self):
     st = """do () () {a}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms,
                      [(FORM_TYPE, [(ATOM_TYPE, "do"), (FORM_TYPE, []),
                                    (FORM_TYPE, [(ATOM_TYPE, LISP_NIL)]),
                                    (ATOM_TYPE, "a")])])
예제 #13
0
 def testGetFormsArray2(self):
     st = """x=[]"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(
         forms,
         [(FORM_TYPE, [(ATOM_TYPE, "setf"), (ATOM_TYPE, "x"),
                       (FORM_TYPE, [(ATOM_TYPE, "_make-vector_")])])])
예제 #14
0
 def testGetFormsLetList3(self):
     st = """let (x,y) {a}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms, [(FORM_TYPE, [(ATOM_TYPE, "let"),
                                           (FORM_TYPE, [(ATOM_TYPE, "x"),
                                                        (ATOM_TYPE, "y")]),
                                           (ATOM_TYPE, "a")])])
예제 #15
0
 def testGetFormsFlet2(self):
     st = """flet foo (a,b) {a+b}
                  boo (a,b) {a*b}
                  pr {}
                  {foo(1,2)-boo(3,4)}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms, [(FORM_TYPE, [
         (ATOM_TYPE, "flet"),
         (FORM_TYPE, [(FORM_TYPE, [(ATOM_TYPE, "foo"),
                                   (FORM_TYPE, [(ATOM_TYPE, "a"),
                                                (ATOM_TYPE, "b")]),
                                   (FORM_TYPE, [(ATOM_TYPE, "_+_"),
                                                (ATOM_TYPE, "a"),
                                                (ATOM_TYPE, "b")])]),
                      (FORM_TYPE, [(ATOM_TYPE, "boo"),
                                   (FORM_TYPE, [(ATOM_TYPE, "a"),
                                                (ATOM_TYPE, "b")]),
                                   (FORM_TYPE, [(ATOM_TYPE, "_*_"),
                                                (ATOM_TYPE, "a"),
                                                (ATOM_TYPE, "b")])]),
                      (FORM_TYPE, [(ATOM_TYPE, "pr"), (FORM_TYPE, [])])]),
         (FORM_TYPE, [(ATOM_TYPE, "_-_"),
                      (FORM_TYPE, [(ATOM_TYPE, "foo"), (ATOM_TYPE, "1"),
                                   (ATOM_TYPE, "2")]),
                      (FORM_TYPE, [(ATOM_TYPE, "boo"), (ATOM_TYPE, "3"),
                                   (ATOM_TYPE, "4")])])
     ])])
예제 #16
0
 def testGetFormsOperForm22(self):
     st = """x+-y"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms,
                      [(FORM_TYPE, [(ATOM_TYPE, "_+_"), (ATOM_TYPE, "x"),
                                    (FORM_TYPE, [(ATOM_TYPE, "_unary-_"),
                                                 (ATOM_TYPE, "y")])])])
예제 #17
0
 def testGetFormDict1(self):
     st = """x={}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(
         forms,
         [(FORM_TYPE, [(ATOM_TYPE, "setf"), (ATOM_TYPE, "x"),
                       (FORM_TYPE, [(ATOM_TYPE, "_make-hash-table_")])])])
예제 #18
0
 def testGetFormsString2(self):
     st = """x="Hello, "+"World!" """
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(
         forms, [(FORM_TYPE, [(ATOM_TYPE, "setf"), (ATOM_TYPE, "x"),
                              (FORM_TYPE, [(ATOM_TYPE, "_+_"),
                                           (ATOM_TYPE, "\"Hello, \""),
                                           (ATOM_TYPE, "\"World!\"")])])])
예제 #19
0
 def testGetFormsBlockForm10(self):
     st = """def setter foo {}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms,
                      [(FORM_TYPE, [(ATOM_TYPE, "defun"),
                                    (FORM_TYPE, [(ATOM_TYPE, "setf"),
                                                 (ATOM_TYPE, "foo")]),
                                    (FORM_TYPE, [])])])
예제 #20
0
 def testGetFormsCLisp1(self):
     st = """x=cl{{(- 1 2)}}-3\n"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms,
                      [(FORM_TYPE, [(ATOM_TYPE, "setf"), (ATOM_TYPE, "x"),
                                    (FORM_TYPE, [(ATOM_TYPE, "_-_"),
                                                 (ATOM_TYPE, "(- 1 2)\n"),
                                                 (ATOM_TYPE, "3")])])])
예제 #21
0
 def testGetFormsFunc4(self):
     st = """x=foo(a,b)"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms,
                      [(FORM_TYPE, [(ATOM_TYPE, "setf"), (ATOM_TYPE, "x"),
                                    (FORM_TYPE, [(ATOM_TYPE, "foo"),
                                                 (ATOM_TYPE, "a"),
                                                 (ATOM_TYPE, "b")])])])
예제 #22
0
 def testGetFormsBracketForm4(self):
     st = """~() ; comment here
             ~()
             ~()"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms, [(FORM_TYPE, []),
                              (COMMENT_TYPE, "; comment here"),
                              (FORM_TYPE, []), (FORM_TYPE, [])])
예제 #23
0
 def testGetFormsComplexNum2(self):
     st = """x=#c(3.4e-10,23/45)"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms,
                      [(FORM_TYPE, [(ATOM_TYPE, "setf"), (ATOM_TYPE, "x"),
                                    (FORM_TYPE, [(ATOM_TYPE, "complex"),
                                                 (ATOM_TYPE, "3.4e-10"),
                                                 (ATOM_TYPE, "23/45")])])])
예제 #24
0
 def testGetFormsUse5(self):
     st = """use {x=a,y=b}
             a(1)
             b(2)"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms,
                      [(FORM_TYPE, [(ATOM_TYPE, "x"), (ATOM_TYPE, "1")]),
                       (FORM_TYPE, [(ATOM_TYPE, "y"), (ATOM_TYPE, "2")])])
예제 #25
0
 def testGetFormsLambdaList9(self):
     st = """def foo(a,b=?bPresent) {}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms, [(FORM_TYPE, [
         (ATOM_TYPE, "defun"), (ATOM_TYPE, "foo"),
         (FORM_TYPE, [(ATOM_TYPE, "a"), (ATOM_TYPE, "&optional"),
                      (FORM_TYPE, [(ATOM_TYPE, "b"), (ATOM_TYPE, "nil"),
                                   (ATOM_TYPE, "bPresent")])])
     ])])
예제 #26
0
 def testGetFormGetitem10(self):
     st = """a[->9,2]"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(
         forms, [(FORM_TYPE, [(ATOM_TYPE, "_getitem_"), (ATOM_TYPE, "a"),
                              (FORM_TYPE, [(ATOM_TYPE, "_make-slice_"),
                                           (ATOM_TYPE, "nil"),
                                           (ATOM_TYPE, "9"),
                                           (ATOM_TYPE, "2")])])])
예제 #27
0
 def testGetFormsStruct2(self):
     st = """struct foo {a b
                         c}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms,
                      [(FORM_TYPE, [(ATOM_TYPE, "defstruct"),
                                    (FORM_TYPE, [(ATOM_TYPE, "foo")]),
                                    (ATOM_TYPE, "a"), (ATOM_TYPE, "b"),
                                    (ATOM_TYPE, "c")])])
예제 #28
0
 def testGetFormsBreak3(self):
     st = """break from blockName x=3"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms,
                      [(FORM_TYPE, [(ATOM_TYPE, "return-from"),
                                    (ATOM_TYPE, "blockName"),
                                    (FORM_TYPE, [(ATOM_TYPE, "setf"),
                                                 (ATOM_TYPE, "x"),
                                                 (ATOM_TYPE, "3")])])])
예제 #29
0
 def testGetFormsReturn2(self):
     st = """def foo {return a}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms,
                      [(FORM_TYPE, [(ATOM_TYPE, "defun"),
                                    (ATOM_TYPE, "foo"), (FORM_TYPE, []),
                                    (FORM_TYPE, [(ATOM_TYPE, "return-from"),
                                                 (ATOM_TYPE, "foo"),
                                                 (ATOM_TYPE, "a")])])])
예제 #30
0
 def testGetFormsBlockForm4(self):
     st = """def foo ()
                 {~()
                  ~()}"""
     forms = getForms(GrowingList(StringIO.StringIO(st)), LevelInfo())
     self.assertEqual(forms, [(FORM_TYPE, [(ATOM_TYPE, "defun"),
                                           (ATOM_TYPE, "foo"),
                                           (FORM_TYPE, []), (FORM_TYPE, []),
                                           (FORM_TYPE, [])])])