Exemple #1
0
 def test_full_tokenise(self):
     line = """["Jane" "Doe" nil "Fake Pty Ltd" (["Mobile" "+61 4123 456 789"] ["Home" "61 2 9876 5432"]) nil ("*****@*****.**") ((creation-date . "2001-01-01") (timestamp . "2002-02-02")) nil]"""
     tokens = [
         "Jane", "Doe", "nil", "Fake Pty Ltd", '(', '[', "Mobile",
         "+61 4123 456 789", ']', '[', "Home", "61 2 9876 5432", ']', ')',
         'nil', '(', "*****@*****.**", ')', '(', '(', 'creation-date',
         '.', "2001-01-01", ')', '(', 'timestamp', '.', "2002-02-02", ')',
         ')', 'nil'
     ]
     self.assertEqual(tokenise(line), tokens)
Exemple #2
0
 def test_parse_full_tokenise(self):
     line = """["Jane" "Doe" nil "Fake Pty Ltd" (["Mobile" "+61 4123 456 789"] ["Home" "61 2 9876 5432"]) nil ("*****@*****.**") ((creation-date . "2001-01-01") (timestamp . "2002-02-02")) nil]"""
     self.assertEqual(parse(tokenise(line)), [
         "Jane", "Doe", "nil", "Fake Pty Ltd",
         [('Mobile', "+61 4123 456 789"),
          ("Home", "61 2 9876 5432")], 'nil', ["*****@*****.**"], {
              'creation-date': "2001-01-01",
              'timestamp': "2002-02-02"
          }, 'nil'
     ])
Exemple #3
0
 def test_trivial_tokenise(self):
     line = """["Hi" "There"]"""
     self.assertEqual(tokenise(line), ['Hi', 'There'])
Exemple #4
0
 def test_parse_a_bit_complicated(self):
     tokens = tokenise("""["Jane" "Doe" nil nil (["Mobile" "+61 4123 456 789"])]""")
     self.assertEqual(parse(tokens), ['Jane', 'Doe', 'nil', 'nil', [("Mobile", "+61 4123 456 789")]])
Exemple #5
0
 def test_full_tokenise(self):
     line = """["Jane" "Doe" nil "Fake Pty Ltd" (["Mobile" "+61 4123 456 789"] ["Home" "61 2 9876 5432"]) nil ("*****@*****.**") ((creation-date . "2001-01-01") (timestamp . "2002-02-02")) nil]"""
     tokens = ["Jane", "Doe", "nil", "Fake Pty Ltd", '(', '[', "Mobile", "+61 4123 456 789", ']', '[', "Home", "61 2 9876 5432", ']', ')', 'nil', '(', "*****@*****.**", ')', '(', '(', 'creation-date', '.', "2001-01-01", ')', '(', 'timestamp', '.', "2002-02-02", ')', ')', 'nil']
     self.assertEqual(tokenise(line), tokens)
Exemple #6
0
 def test_tokenise_pairs_in_multis(self):
     line = """[(["Mobile" "123"] ["Home" "456"])]"""
     self.assertEqual(tokenise(line), ['(', '[', 'Mobile', '123', ']', '[', 'Home', '456', ']', ')'])
Exemple #7
0
 def test_tokenise_pair(self):
     line = """[["foo" "bar"]]"""
     self.assertEqual(tokenise(line), ['[', 'foo', 'bar', ']'])
Exemple #8
0
 def test_tokenise_with_multis_with_multiple_values(self):
     line = """[("foo" "bar")]"""
     self.assertEqual(tokenise(line), ['(', 'foo', 'bar', ')'])
Exemple #9
0
 def test_tokenise_with_multis_that_have_one_value(self):
     line = """[("foo")]"""
     self.assertEqual(tokenise(line), ['(', 'foo', ')'])
Exemple #10
0
 def test_trivial_tokenise(self):
     line = """["Hi" "There"]"""
     self.assertEqual(tokenise(line), ['Hi', 'There'])
Exemple #11
0
 def test_parse_a_bit_complicated(self):
     tokens = tokenise(
         """["Jane" "Doe" nil nil (["Mobile" "+61 4123 456 789"])]""")
     self.assertEqual(
         parse(tokens),
         ['Jane', 'Doe', 'nil', 'nil', [("Mobile", "+61 4123 456 789")]])
Exemple #12
0
 def test_tokenise_pairs_in_multis(self):
     line = """[(["Mobile" "123"] ["Home" "456"])]"""
     self.assertEqual(
         tokenise(line),
         ['(', '[', 'Mobile', '123', ']', '[', 'Home', '456', ']', ')'])
Exemple #13
0
 def test_tokenise_pair(self):
     line = """[["foo" "bar"]]"""
     self.assertEqual(tokenise(line), ['[', 'foo', 'bar', ']'])
Exemple #14
0
 def test_tokenise_with_multis_with_multiple_values(self):
     line = """[("foo" "bar")]"""
     self.assertEqual(tokenise(line), ['(', 'foo', 'bar', ')'])
Exemple #15
0
 def test_parse_full_tokenise(self):
     line = """["Jane" "Doe" nil "Fake Pty Ltd" (["Mobile" "+61 4123 456 789"] ["Home" "61 2 9876 5432"]) nil ("*****@*****.**") ((creation-date . "2001-01-01") (timestamp . "2002-02-02")) nil]"""
     self.assertEqual(parse(tokenise(line)), ["Jane", "Doe", "nil", "Fake Pty Ltd", [('Mobile', "+61 4123 456 789"), ("Home", "61 2 9876 5432")], 'nil', ["*****@*****.**"], {'creation-date': "2001-01-01", 'timestamp': "2002-02-02"}, 'nil'])
Exemple #16
0
 def test_tokenise_with_multis_that_have_one_value(self):
     line = """[("foo")]"""
     self.assertEqual(tokenise(line), ['(', 'foo', ')'])
Exemple #17
0
 def test_trivial_tokenise_with_spaces(self):
     line = """["Hi There"]"""
     self.assertEqual(tokenise(line), ['Hi There'])
Exemple #18
0
 def test_trivial_tokenise_with_spaces(self):
     line = """["Hi There"]"""
     self.assertEqual(tokenise(line), ['Hi There'])