Use table-driven tests for specific parsers
This commit is contained in:
parent
5869c1ea18
commit
f248ece3aa
12 changed files with 355 additions and 167 deletions
16
spec/runtime/languages/arithmetic/errors.txt
Normal file
16
spec/runtime/languages/arithmetic/errors.txt
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
=====================================================
|
||||
recovers from errors at the top level
|
||||
=====================================================
|
||||
x * * y
|
||||
---
|
||||
(ERROR)
|
||||
|
||||
=====================================================
|
||||
recovers from errors inside parenthesized expressions
|
||||
=====================================================
|
||||
x + (y * + z) * 5
|
||||
---
|
||||
(expression
|
||||
(term (factor (variable)))
|
||||
(plus)
|
||||
(term (factor (ERROR)) (times) (factor (number))))
|
||||
54
spec/runtime/languages/arithmetic/main.txt
Normal file
54
spec/runtime/languages/arithmetic/main.txt
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
====================
|
||||
parses numbers
|
||||
===================
|
||||
5
|
||||
---
|
||||
(expression (term (factor (number))))
|
||||
|
||||
===================
|
||||
parses variables
|
||||
===================
|
||||
x
|
||||
---
|
||||
(expression (term (factor (variable))))
|
||||
|
||||
===================
|
||||
parses products
|
||||
===================
|
||||
x * x
|
||||
---
|
||||
(expression (term
|
||||
(factor (variable))
|
||||
(times)
|
||||
(factor (variable))))
|
||||
|
||||
===================
|
||||
parses sums
|
||||
===================
|
||||
x + x
|
||||
---
|
||||
(expression
|
||||
(term (factor (variable)))
|
||||
(plus)
|
||||
(term (factor (variable))))
|
||||
|
||||
====================
|
||||
parses complex trees
|
||||
====================
|
||||
x * y + z * a
|
||||
---
|
||||
(expression
|
||||
(term (factor (variable)) (times) (factor (variable)))
|
||||
(plus)
|
||||
(term (factor (variable)) (times) (factor (variable))))
|
||||
|
||||
=================================
|
||||
handles parenthesized expressions
|
||||
=================================
|
||||
x * (y + z)
|
||||
---
|
||||
(expression
|
||||
(term (factor (variable))
|
||||
(times)
|
||||
(factor (expression (term (factor (variable))) (plus) (term (factor (variable)))))))
|
||||
|
||||
33
spec/runtime/languages/json/errors.txt
Normal file
33
spec/runtime/languages/json/errors.txt
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
==============================
|
||||
recovers from top-level errors
|
||||
==============================
|
||||
[}
|
||||
---
|
||||
(ERROR)
|
||||
|
||||
==================================
|
||||
recovers from errors inside arrays
|
||||
==================================
|
||||
[1,,2]
|
||||
---
|
||||
(value (array
|
||||
(value (number))
|
||||
(ERROR)
|
||||
(value (number))))
|
||||
|
||||
==================================
|
||||
recovers from errors inside objects
|
||||
==================================
|
||||
{ "key1": 1, 5 }
|
||||
---
|
||||
(value (object (string) (value (number)) (ERROR)))
|
||||
|
||||
==========================================
|
||||
recovers from errors inside nested objects
|
||||
==========================================
|
||||
{ "key1": { "key2": 1, 2 }, [, "key3": 3 }
|
||||
---
|
||||
(value (object
|
||||
(string) (value (object (string) (value (number)) (ERROR)))
|
||||
(ERROR)
|
||||
(string) (value (number))))
|
||||
44
spec/runtime/languages/json/main.txt
Normal file
44
spec/runtime/languages/json/main.txt
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
====================
|
||||
parses empty objects
|
||||
====================
|
||||
{}
|
||||
---
|
||||
(value (object))
|
||||
|
||||
===================
|
||||
parses empty arrays
|
||||
===================
|
||||
[]
|
||||
---
|
||||
(value (array))
|
||||
|
||||
===================
|
||||
parses arrays
|
||||
===================
|
||||
[
|
||||
1, 2, 3,
|
||||
{ "stuff": "good" }
|
||||
]
|
||||
---
|
||||
(value (array
|
||||
(value (number))
|
||||
(value (number))
|
||||
(value (number))
|
||||
(value (object
|
||||
(string) (value (string))
|
||||
))
|
||||
))
|
||||
|
||||
===================
|
||||
parses long objects
|
||||
===================
|
||||
{
|
||||
"key1": "value1",
|
||||
"key2": 1
|
||||
}
|
||||
---
|
||||
(value (object
|
||||
(string) (value (string))
|
||||
(string) (value (number))
|
||||
))
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue