move to typed structure
on the way to removing the language, the at needs to be replaced with a typed structure.
This commit is contained in:
@ -8,8 +8,10 @@ to run just a single, replace all with what you want to test. Minitest accept a
|
||||
|
||||
ruby test/test_class.rb -n test_class_ops_parse
|
||||
|
||||
Notice tough the "_parse" at the end, while you will find no such function. The Magic (explained below) renerates three
|
||||
functions per case. Your options are "_parse" , "_transform" , or if it's really bad, "_ast" (this should really work when the previous two work)
|
||||
Notice tough the "_parse" at the end, while you will find no such function.
|
||||
The Magic (explained below) generates three functions per case.
|
||||
Your options are "_parse" , "_transform" , or if it's really bad, "_ast"
|
||||
(this should really work when the previous two work)
|
||||
|
||||
### Directories
|
||||
|
||||
@ -26,7 +28,7 @@ Apart from just plain more tests, two additional directories are planned. One is
|
||||
|
||||
Parsing is a two step process with parslet:
|
||||
- parse takes an input and outputs hashes/arrays with basic types
|
||||
- tramsform takes the output of parse and generates an ast (as specified by the transformation)
|
||||
- transform takes the output of parse and generates an ast (as specified by the transformation)
|
||||
|
||||
A test tests both phases separately and again together.
|
||||
Each test must thus specify (as instance variables):
|
||||
|
@ -1,5 +0,0 @@
|
||||
[42, foo]
|
||||
-- -- --
|
||||
s(:array,
|
||||
s(:int, 42),
|
||||
s(:name, :foo))
|
@ -1,10 +0,0 @@
|
||||
[ 3 + 4 , foo(22) ]
|
||||
-- -- --
|
||||
s(:array,
|
||||
s(:operator_value, :+,
|
||||
s(:int, 3),
|
||||
s(:int, 4)),
|
||||
s(:call,
|
||||
s(:name, :foo),
|
||||
s(:arguments,
|
||||
s(:int, 22))))
|
@ -1,4 +0,0 @@
|
||||
[42]
|
||||
-- -- --
|
||||
s(:array,
|
||||
s(:int, 42))
|
@ -1,6 +0,0 @@
|
||||
{ foo => 33 }
|
||||
-- -- --
|
||||
s(:hash,
|
||||
s(:assoc,
|
||||
s(:name, :foo),
|
||||
s(:int, 33)))
|
@ -1,6 +0,0 @@
|
||||
{ foo => true }
|
||||
-- -- --
|
||||
s(:hash,
|
||||
s(:assoc,
|
||||
s(:name, :foo),
|
||||
s(:true)))
|
@ -1,9 +0,0 @@
|
||||
{foo => 33 , bar => 42}
|
||||
-- -- --
|
||||
s(:hash,
|
||||
s(:assoc,
|
||||
s(:name, :foo),
|
||||
s(:int, 33)),
|
||||
s(:assoc,
|
||||
s(:name, :bar),
|
||||
s(:int, 42)))
|
@ -34,6 +34,12 @@ class TestAll < MiniTest::Test
|
||||
end
|
||||
end
|
||||
assert_equal sexp , result
|
||||
check_transform sexp
|
||||
end
|
||||
|
||||
def check_transform sexp
|
||||
code = Soml.ast_to_code sexp
|
||||
assert code.is_a?(Soml::Code) , "Returned #{code}"
|
||||
end
|
||||
|
||||
# this creates test methods dynamically. For each test_* method we create
|
||||
|
Reference in New Issue
Block a user