Skip to content

Commit e8921dc

Browse files
authored
Merge pull request #1 from hellerve/codex/update-map.apply-to-join-arguments-as-strings
Fix Map.apply arg list message and add tests
2 parents 164d77f + 3d91ab9 commit e8921dc

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

mae.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def evaluate(self, m):
9393
def apply(self, args, m):
9494
if len(args) != 1:
9595
raise RunError(
96-
f"map can only applied to one argument (got ({', '.join(args)}))!"
96+
f"map can only applied to one argument (got ({', '.join(str(a) for a in args)}))!"
9797
)
9898

9999
return self.m.get(m.evaluate(args[0]), Map({}))

tests/__init__.py

Whitespace-only changes.

tests/test_map.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import unittest
2+
from mae import Mae, Map, Var, RunError
3+
4+
class MapApplyTests(unittest.TestCase):
5+
def test_multiple_arguments_raises_runerror(self):
6+
env = Mae()
7+
m = Map({})
8+
args = [Var('a'), Var('b')]
9+
with self.assertRaises(RunError) as cm:
10+
m.apply(args, env)
11+
msg = str(cm.exception)
12+
self.assertIn('map can only applied to one argument', msg)
13+
# ensure all arguments are listed in the message
14+
self.assertIn('a', msg)
15+
self.assertIn('b', msg)
16+
17+
if __name__ == '__main__':
18+
unittest.main()

0 commit comments

Comments
 (0)