Skip to content

Commit

Permalink
Add test for substr of non-string argument
Browse files Browse the repository at this point in the history
  • Loading branch information
solleks committed Jun 10, 2020
1 parent 529c4be commit 47d174b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/test_minilinq.py
Expand Up @@ -134,7 +134,8 @@ def test_template(self):

def test_substr(self):
env = BuiltInEnv({'single_byte_chars': u'abcdefghijklmnopqrstuvwxyz',
'multi_byte_chars': u'αβγδεζηθικλμνξοπρςστυφχψω'
'multi_byte_chars': u'αβγδεζηθικλμνξοπρςστυφχψω',
'an_integer': 123456
})
assert Apply(Reference('substr'), Reference('single_byte_chars'),
Literal(-4), Literal(30)).eval(env) == None
Expand All @@ -150,6 +151,7 @@ def test_substr(self):
Literal(14), Literal(13)).eval(env) == u''
assert Apply(Reference('substr'), Reference('single_byte_chars'),
Literal(5), Literal(-1)).eval(env) == None

assert Apply(Reference('substr'), Reference('multi_byte_chars'),
Literal(-4), Literal(30)).eval(env) == None
assert Apply(Reference('substr'), Reference('multi_byte_chars'),
Expand All @@ -165,6 +167,17 @@ def test_substr(self):
assert Apply(Reference('substr'), Reference('multi_byte_chars'),
Literal(5), Literal(-1)).eval(env) == None

assert Apply(Reference('substr'), Reference('an_integer'),
Literal(-1), Literal(3)).eval(env) == None
assert Apply(Reference('substr'), Reference('an_integer'),
Literal(0), Literal(6)).eval(env) == u'123456'
assert Apply(Reference('substr'), Reference('an_integer'),
Literal(2), Literal(4)).eval(env) == u'34'
assert Apply(Reference('substr'), Reference('an_integer'),
Literal(4), Literal(2)).eval(env) == u''
assert Apply(Reference('substr'), Reference('an_integer'),
Literal(5), Literal(-1)).eval(env) == None

def test_map(self):
env = BuiltInEnv() | DictEnv({})

Expand Down

0 comments on commit 47d174b

Please sign in to comment.