|
1 | 1 | import itertools |
2 | | -import unittest |
3 | 2 |
|
4 | 3 | from parameterized import parameterized |
5 | 4 |
|
@@ -132,12 +131,25 @@ def test_StringLiteral(self): |
132 | 131 | self.assertIsInstance(string_literal.value, jast.StringLiteral) |
133 | 132 | self.assertEqual("foo", string_literal.value.value) |
134 | 133 |
|
135 | | - @unittest.skip("TextBlock does not work as expected") |
136 | 134 | def test_TextBlock(self): |
137 | | - text_block = jast.parse('"""foo"""', jast.ParseMode.EXPR) |
| 135 | + text_block = jast.parse('"""\nfoo"""', jast.ParseMode.EXPR) |
138 | 136 | self.assertIsInstance(text_block, jast.Constant) |
139 | 137 | self.assertIsInstance(text_block.value, jast.TextBlock) |
140 | | - self.assertEqual("foo", text_block.value.value) |
| 138 | + self.assertEqual(["foo"], text_block.value.value) |
| 139 | + |
| 140 | + def test_TextBlock_new_line(self): |
| 141 | + text_block = jast.parse('"""\nfoo\n"""', jast.ParseMode.EXPR) |
| 142 | + self.assertIsInstance(text_block, jast.Constant) |
| 143 | + self.assertIsInstance(text_block.value, jast.TextBlock) |
| 144 | + self.assertEqual(["foo", ""], text_block.value.value) |
| 145 | + |
| 146 | + def test_TextBlock_different_indents(self): |
| 147 | + text_block = jast.parse( |
| 148 | + '"""\n foo\n\t bar\n \n\t\t\tbaz\n """', jast.ParseMode.EXPR |
| 149 | + ) |
| 150 | + self.assertIsInstance(text_block, jast.Constant) |
| 151 | + self.assertIsInstance(text_block.value, jast.TextBlock) |
| 152 | + self.assertEqual(["foo", " bar", "", "\tbaz", ""], text_block.value.value) |
141 | 153 |
|
142 | 154 | def test_Null(self): |
143 | 155 | null = jast.parse("null", jast.ParseMode.EXPR) |
|
0 commit comments