def test_quoted_multiline(self): data = "'meow\n meow\n meow'" self.assertMark(_get_offset_mark(data, 0), (0, 1), 1) self.assertMark(_get_offset_mark(data, 5), (1, 2), 8) self.assertMark(_get_offset_mark(data, 10), (2, 2), 15) self.assertMark(_get_offset_mark(data, 14), (2, 6), 19) # Past the parsed string. self.assertMark(_get_offset_mark(data, 15), (2, 7), 20)
def test_quoted(self): data = "'meow'" self.assertMark(_get_offset_mark(data, 0), (0, 1), 1) self.assertMark(_get_offset_mark(data, 2), (0, 3), 3) # Past the parsed string. self.assertMark(_get_offset_mark(data, 5), (0, 6), 6) data = '"meow"' self.assertMark(_get_offset_mark(data, 0), (0, 1), 1) self.assertMark(_get_offset_mark(data, 2), (0, 3), 3)
def test_plain(self): data = 'meow' self.assertMark(_get_offset_mark(data, 0), (0, 0), 0) self.assertMark(_get_offset_mark(data, 2), (0, 2), 2) data = 'meow[meow]' self.assertMark(_get_offset_mark(data, 0), (0, 0), 0) self.assertMark(_get_offset_mark(data, 4), (0, 4), 4) data = 'meow\n meow' self.assertMark(_get_offset_mark(data, 5), (1, 2), 7)
def test_block_keep_newlines(self): data = dedent(""" |+ meow """).lstrip() self.assertMark(_get_offset_mark(data, 5), (4, 0), 12)
def test_anchor_block(self): data = dedent(""" &anchor > meow meow """).strip() self.assertMark(_get_offset_mark(data, 0), (1, 2), 12) self.assertMark(_get_offset_mark(data, 3), (1, 5), 15) self.assertMark(_get_offset_mark(data, 4), (1, 6), 16) self.assertMark(_get_offset_mark(data, 5), (2, 2), 19) self.assertMark(_get_offset_mark(data, 8), (2, 5), 22) self.assertMark(_get_offset_mark(data, 9), (2, 6), 23)
def test_block_indent_level(self): data = dedent(""" >2 meow meow """).strip() self.assertMark(_get_offset_mark(data, 0), (1, 2), 5) self.assertMark(_get_offset_mark(data, 5), (1, 7), 10) self.assertMark(_get_offset_mark(data, 6), (1, 8), 11) self.assertMark(_get_offset_mark(data, 7), (2, 2), 14) self.assertMark(_get_offset_mark(data, 12), (2, 7), 19) self.assertMark(_get_offset_mark(data, 13), (2, 8), 20)
def test_block(self): data = dedent(""" > meow meow """).strip() self.assertMark(_get_offset_mark(data, 0), (1, 2), 4) self.assertMark(_get_offset_mark(data, 3), (1, 5), 7) self.assertMark(_get_offset_mark(data, 4), (1, 6), 8) self.assertMark(_get_offset_mark(data, 5), (2, 2), 11) self.assertMark(_get_offset_mark(data, 8), (2, 5), 14) self.assertMark(_get_offset_mark(data, 9), (2, 6), 15) data = dedent(""" > meow """).lstrip() self.assertMark(_get_offset_mark(data, 5), (3, 0), 10)
def test_anchor(self): data = '&anchor meow' self.assertMark(_get_offset_mark(data, 0), (0, 8), 8) self.assertMark(_get_offset_mark(data, 2), (0, 10), 10)
def test_block_empty(self): data = dedent(""" > """).strip() self.assertMark(_get_offset_mark(data, 0), (0, 1), 1) self.assertMark(_get_offset_mark(data, 1), (0, 1), 1)
def test_quoted_escape(self): data = "'meow \\ meow'" self.assertMark(_get_offset_mark(data, 0), (0, 1), 1) self.assertMark(_get_offset_mark(data, 5), (0, 6), 6) self.assertMark(_get_offset_mark(data, 7), (0, 8), 8) data = "'meow '' meow'" self.assertMark(_get_offset_mark(data, 0), (0, 1), 1) self.assertMark(_get_offset_mark(data, 5), (0, 6), 6) self.assertMark(_get_offset_mark(data, 7), (0, 9), 9) data = '"meow \\n meow"' self.assertMark(_get_offset_mark(data, 0), (0, 1), 1) self.assertMark(_get_offset_mark(data, 5), (0, 6), 6) self.assertMark(_get_offset_mark(data, 7), (0, 9), 9) data = '"meow \\x0a meow"' self.assertMark(_get_offset_mark(data, 0), (0, 1), 1) self.assertMark(_get_offset_mark(data, 5), (0, 6), 6) self.assertMark(_get_offset_mark(data, 7), (0, 11), 11) data = '"meow \\\n meow"' self.assertMark(_get_offset_mark(data, 0), (0, 1), 1) self.assertMark(_get_offset_mark(data, 5), (0, 6), 6) self.assertMark(_get_offset_mark(data, 7), (1, 2), 10)