Beispiel #1
0
 def test_rest_bytestring(self):
     self.assertEqual(
         evaluate_with_prelude(parse_one(lex(u'(rest #bytes("abc"))'))),
         Bytestring([ord(c) for c in b"bc"]))
Beispiel #2
0
 def test_rest_string(self):
     self.assertEqual(
         evaluate_with_prelude(parse_one(lex(u'(rest "abc")'))),
         String(list(u"bc")))
Beispiel #3
0
 def test_last_string(self):
     self.assertEqual(
         evaluate_with_prelude(parse_one(lex(u'(last "abc")'))),
         Character(u'c'))
Beispiel #4
0
 def test_push_returns_null(self):
     self.assertEqual(
         evaluate_with_prelude(parse_one(lex(
             u"(push! (quote ()) 1)"))),
         NULL)
Beispiel #5
0
 def test_fifth_string(self):
     self.assertEqual(
         evaluate_with_prelude(parse_one(lex(u'(fifth "abcde")'))),
         Character(u'e'))
Beispiel #6
0
 def test_last_bytestring(self):
     self.assertEqual(
         evaluate_with_prelude(parse_one(lex(u'(last #bytes("abc"))'))),
         Integer.fromint(99))
Beispiel #7
0
 def test_second_string(self):
     self.assertEqual(
         evaluate_with_prelude(parse_one(lex(u'(second "abc")'))),
         Character(u'b'))
Beispiel #8
0
 def test_fifth_bytestring(self):
     self.assertEqual(
         evaluate_with_prelude(parse_one(lex(u'(fifth #bytes("abcde"))'))),
         Integer.fromint(101))
Beispiel #9
0
 def test_map_string(self):
     self.assertEqual(
         evaluate_with_prelude(parse_one(lex(u'(filter (lambda (x) (equal? x \'b\')) "abc")'))),
         String(list(u"b")))
Beispiel #10
0
 def test_map_bytestring(self):
     self.assertEqual(
         evaluate_with_prelude(parse_one(lex(u'(filter (lambda (x) (equal? x 98)) #bytes("abc"))'))),
         Bytestring([ord("b")]))
Beispiel #11
0
 def test_map_string(self):
     self.assertEqual(
         evaluate_with_prelude(parse_one(lex(u'(map (lambda (x) \'z\') "abc")'))),
         String(list(u"zzz")))
Beispiel #12
0
 def test_map_bytestring(self):
     self.assertEqual(
         evaluate_with_prelude(parse_one(lex(u'(map (lambda (x) (+ x 1)) #bytes("abc"))'))),
         Bytestring([ord(c) for c in "bcd"]))
Beispiel #13
0
 def test_for_each(self):
     self.assertEqual(
         evaluate_with_prelude(parse_one(lex(u"""(let (total 0 numbers (list 1 2 3 4))
         (for-each number numbers (set! total (+ total number)))
         total)"""))),
         Integer.fromint(10))