Skip to content

Commit

Permalink
+ Version 0.2.4
Browse files Browse the repository at this point in the history
+ Fixed $ escaping
+ Added tests
  • Loading branch information
Genarito committed May 5, 2021
1 parent 73baeb8 commit fd70243
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
3 changes: 2 additions & 1 deletion gura/GuraParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,8 @@ def basic_string(self) -> str:
'r': '\r',
't': '\t',
'"': '"',
'\\': '\\'
'\\': '\\',
'$': '$'
}

while True:
Expand Down
2 changes: 1 addition & 1 deletion gura/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
VariableNotDefinedError, DuplicatedImportError, loads, dumps
from gura.Parser import ParseError

__version__ = "0.2.3"
__version__ = "0.2.4"

loads = loads
dumps = dumps
Expand Down
12 changes: 9 additions & 3 deletions tests/strings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ class TestStringsGura(unittest.TestCase):
def setUp(self):
self.file_dir = os.path.dirname(os.path.abspath(__file__))

escaped_value = '$name is cool'

self.expected_basic = {
"str": "I'm a string. \"You can quote me\". Na\bme\tJos\u00E9\nLocation\tSF.",
"str_2": "I'm a string. \"You can quote me\". Na\bme\tJos\U000000E9\nLocation\tSF.",
"with_var": "Gura is cool",
"escaped_var": escaped_value,
"with_env_var": "Gura is very cool"
}

Expand All @@ -36,20 +39,23 @@ def setUp(self):
'str_4': 'Here are two quotation marks: "". Simple enough.',
'str_5': 'Here are three quotation marks: """.',
'str_6': 'Here are fifteen quotation marks: """"""""""""""".',
"escaped_var": escaped_value,
}

self.expected_literal = {
'quoted': 'Tom "Dubs" Preston-Werner',
'quoted': 'John "Dog lover" Wick',
'regex': '<\\i\\c*\\s*>',
'winpath': 'C:\\Users\\nodejs\\templates',
'winpath2': '\\\\ServerX\\admin$\\system32\\',
'with_var': '$no_parsed variable!'
'with_var': '$no_parsed variable!',
"escaped_var": escaped_value
}

self.expected_multiline_literal = {
'lines': 'The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n',
'regex2': "I [dw]on't need \\d{2} apples",
'with_var': '$no_parsed variable!'
'with_var': '$no_parsed variable!',
"escaped_var": escaped_value
}
self.maxDiff = 4096

Expand Down
1 change: 1 addition & 0 deletions tests/strings/tests-files/basic.ura
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ $name: "Gura"
str: "I'm a string. \"You can quote me\". Na\bme\tJos\u00E9\nLocation\tSF."
str_2: "I'm a string. \"You can quote me\". Na\bme\tJos\U000000E9\nLocation\tSF."
with_var: "$name is cool"
escaped_var: "\$name is cool"
with_env_var: "$name is $env_var_value cool" # $env_var_value is defined in corresponding test.py
5 changes: 3 additions & 2 deletions tests/strings/tests-files/literal.ura
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# What you see is what you get.
winpath: 'C:\Users\nodejs\templates'
winpath2: '\\ServerX\admin$\system32\'
quoted: 'Tom "Dubs" Preston-Werner'
quoted: 'John "Dog lover" Wick'
regex: '<\i\c*\s*>'
with_var: '$no_parsed variable!'
with_var: '$no_parsed variable!'
escaped_var: '$name is cool'
3 changes: 2 additions & 1 deletion tests/strings/tests-files/multiline_basic.ura
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ str_with_backslash_2: """\

str_4: """Here are two quotation marks: "". Simple enough."""
str_5: """Here are three quotation marks: ""\"."""
str_6: """Here are fifteen quotation marks: ""\"""\"""\"""\"""\"."""
str_6: """Here are fifteen quotation marks: ""\"""\"""\"""\"""\"."""
escaped_var: """\$name is cool"""
3 changes: 2 additions & 1 deletion tests/strings/tests-files/multiline_literal.ura
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ trimmed in raw strings.
All other whitespace
is preserved.
'''
with_var: '''$no_parsed variable!'''
with_var: '''$no_parsed variable!'''
escaped_var: '''$name is cool'''

0 comments on commit fd70243

Please sign in to comment.