def test_TryBlob_ErrorWhenForgotBraceEnd(self): with self.assertRaises(errors.Error): mp._TryBlob('{hello-world-ε', 0, 0) with self.assertRaises(errors.Error): mp._TryBlob('{hello-world-ε{}', 0, 0)
def test_TryBlob_OneBlobAndSomethingElse(self): (new_pos, new_line, blob) = mp._TryBlob('{hello} \n', 0, 0) self.assertEqual(7, new_pos) self.assertEqual(0, new_line) self.assertEqual(mp.Token('blob', 'hello', mp.SourcePos(0, 0, 0, 7)), blob)
def test_TryBlob_OneWordSymbolsandNonASCII(self): (new_pos, new_line, blob) = mp._TryBlob('{hello-world-ε}', 0, 0) self.assertEqual(15, new_pos) self.assertEqual(0, new_line) self.assertEqual(mp.Token('blob', 'hello-world-ε', mp.SourcePos(0, 0, 0, 15)), blob)
def test_TryBlob_EvenMoreComplexBlob(self): (new_pos, new_line, blob) = mp._TryBlob('{hello world {lala} \n how are you today{\n{\n}}?}', 0, 0) self.assertEqual(47, new_pos) self.assertEqual(3, new_line) self.assertEqual(mp.Token('blob', 'hello world {lala} \n how are you today{\n{\n}}?', mp.SourcePos(0, 3, 0, 47)), blob)
def test_TryBlob_ComplexBlob(self): (new_pos, new_line, blob) = mp._TryBlob('{hello world \n how are you today?}', 0, 0) self.assertEqual(34, new_pos) self.assertEqual(1, new_line) self.assertEqual(mp.Token('blob', 'hello world \n how are you today?', mp.SourcePos(0, 1, 0, 34)), blob)
def test_TryBlob_OneBlob2(self): (new_pos, new_line, blob) = mp._TryBlob('hello \n {hello}', 10, 1) self.assertEqual(17, new_pos) self.assertEqual(1, new_line) self.assertEqual(mp.Token('blob', 'hello', mp.SourcePos(1, 1, 10, 17)), blob)