from hisscl import parser, ast import unittest import io class TestLiterals(unittest.TestCase): def test_integer(self): val = parser.Parser(io.StringIO('1234'), 'TestLiterals.test_integer')._parse_value() self.assertIsInstance(val, ast.Integer) assert type(val) is ast.Integer self.assertEqual(val.value, 1234) def test_float(self): val = parser.Parser(io.StringIO('1234.5678'), 'TestLiterals.test_float')._parse_value() self.assertIsInstance(val, ast.Float) assert type(val) is ast.Float self.assertEqual(val.value, 1234.5678) def test_string(self): val = parser.Parser(io.StringIO('"test \\" \\u26a7"'), 'TestLiterals.test_string')._parse_value() self.assertIsInstance(val, ast.String) assert type(val) is ast.String self.assertEqual(val.value, 'test " \u26a7') def test_bool(self): val = parser.Parser(io.StringIO('true'), 'TestLiterals.test_bool')._parse_value() self.assertIsInstance(val, ast.Bool) assert type(val) is ast.Bool self.assertEqual(val.value, True) def test_heredoc(self): val = parser.Parser(io.StringIO('<