-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[htm8 cleanup] Add unit test, add TODOs
[doctools refactor] Add static typing
- Loading branch information
Andy C
committed
Jan 15, 2025
1 parent
c9dcc65
commit ea096c6
Showing
6 changed files
with
91 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python2 | ||
from __future__ import print_function | ||
|
||
import unittest | ||
import re | ||
|
||
from data_lang import htm8 | ||
|
||
class RegexTest(unittest.TestCase): | ||
|
||
def testDotAll(self): | ||
# type: () -> None | ||
|
||
# Note that $ matches end of line, not end of string | ||
p1 = re.compile(r'.') | ||
print(p1.match('\n')) | ||
|
||
p2 = re.compile(r'.', re.DOTALL) | ||
print(p2.match('\n')) | ||
|
||
#p3 = re.compile(r'[.\n]', re.VERBOSE) | ||
p3 = re.compile(r'[.\n]') | ||
print(p3.match('\n')) | ||
|
||
print('Negation') | ||
|
||
p4 = re.compile(r'[^>]') | ||
print(p4.match('\n')) | ||
|
||
def testAttrRe(self): | ||
# type: () -> None | ||
_ATTR_RE = htm8._ATTR_RE | ||
m = _ATTR_RE.match(' empty= val') | ||
print(m.groups()) | ||
|
||
|
||
class FunctionsTest(unittest.TestCase): | ||
|
||
def testFindLineNum(self): | ||
# type: () -> None | ||
s = 'foo\n' * 3 | ||
for pos in [1, 5, 10, 50]: # out of bounds | ||
line_num = htm8.FindLineNum(s, pos) | ||
print(line_num) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters