Permalink
Please sign in to comment.
Browse files
Fix 'source' and 'eval' syntax errors to give location info.
Also, error locations work inside here doc! Demos in test/runtime-errors.sh for these cases. TODO: Turn these into proper tests. Details: - New, cleaner parse_lib interface. - New FileLineReader abstraction. - Express StringLineReader in terms of FileLineReader - Thoroughly test the line readers and fix bugs! - New arena.PushSource / PopSource API Other: - Clarify the usage of the readline interface, as it relates to the OSH parser. - Catch exception for 'osh nonexistent.sh' Tests: - Add test cases for 'source' and 'eval' syntax errors. - Document what different shells do. bash does the best. - Move 'eval' test to builtins.test.sh. - Add unit tests for alloc and reader. Unit tests and spec tests all pass.
- Loading branch information...
Showing
with
308 additions
and 103 deletions.
- +30 −24 bin/oil.py
- +20 −10 core/alloc.py
- +55 −0 core/alloc_test.py
- +27 −19 core/cmd_exec.py
- +2 −2 core/cmd_exec_test.py
- +11 −7 core/completion.py
- +5 −0 core/lexer_test.py
- +20 −10 core/reader.py
- +50 −0 core/reader_test.py
- +5 −3 osh/cmd_parse.py
- +1 −1 osh/cmd_parse_test.py
- +1 −0 osh/osh.asdl
- +25 −15 osh/parse_lib.py
- +1 −0 osh/word_parse_test.py
- +5 −0 spec/builtins.test.sh
- +0 −5 spec/smoke.test.sh
- +50 −7 test/runtime-errors.sh
| @@ -0,0 +1,55 @@ | ||
| #!/usr/bin/env python | ||
| """ | ||
| alloc_test.py: Tests for alloc.py | ||
| """ | ||
| import unittest | ||
| import alloc # module under test | ||
| class AllocTest(unittest.TestCase): | ||
| def setUp(self): | ||
| p = alloc.Pool() | ||
| self.arena = p.NewArena() | ||
| def testPool(self): | ||
| arena = self.arena | ||
| arena.PushSource('one.oil') | ||
| line_id = arena.AddLine('line 1', 1) | ||
| self.assertEqual(0, line_id) | ||
| line_id = arena.AddLine('line 2', 2) | ||
| self.assertEqual(1, line_id) | ||
| span_id = arena.AddLineSpan(None) | ||
| self.assertEqual(0, span_id) | ||
| arena.PopSource() | ||
| self.assertEqual(('one.oil', 1), arena.GetDebugInfo(0)) | ||
| self.assertEqual(('one.oil', 2), arena.GetDebugInfo(1)) | ||
| def testPushSource(self): | ||
| arena = self.arena | ||
| arena.PushSource('one.oil') | ||
| arena.AddLine('echo 1a', 1) | ||
| arena.AddLine('source two.oil', 2) | ||
| arena.PushSource('two.oil') | ||
| arena.AddLine('echo 2a', 1) | ||
| id2 = arena.AddLine('echo 2b', 2) # line 2 of two.oil | ||
| arena.PopSource() | ||
| id3 = arena.AddLine('echo 1c', 3) # line 3 of one.oil | ||
| arena.PopSource() | ||
| # TODO: fix these assertions | ||
| self.assertEqual(('two.oil', 2), arena.GetDebugInfo(id2)) | ||
| self.assertEqual(('one.oil', 3), arena.GetDebugInfo(id3)) | ||
| if __name__ == '__main__': | ||
| unittest.main() |
Oops, something went wrong.
0 comments on commit
d422565