parent
461a6933c6
commit
eec72a9fca
@ -14,6 +14,7 @@ module Ruby
|
|||||||
@node.to_s[0 ... 200]
|
@node.to_s[0 ... 200]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# This RubyCompiler compiles incoming ruby (string) into a typed
|
# This RubyCompiler compiles incoming ruby (string) into a typed
|
||||||
# version of theast, with the help of the parser gem.
|
# version of theast, with the help of the parser gem.
|
||||||
# The parser outputs an abstract ast (nodes)
|
# The parser outputs an abstract ast (nodes)
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
# Mains testing
|
# Mains testing
|
||||||
|
|
||||||
Test methods by their output and exit codes (return, since it is the main).
|
Test methods by their output and exit codes (return, since it is the main).
|
||||||
|
|
||||||
There are only two tests here, one for interpreter, one for arm.
|
There are only two tests here (lus one, see below), one for interpreter, one for arm.
|
||||||
Both run the same tests. The actual ruby code that is run is in the source dir.
|
Both run the same tests. The actual ruby code that is run is in the source dir.
|
||||||
Test methods are generated, one for each source file.
|
Test methods are generated, one for each source file.
|
||||||
|
|
||||||
|
## Files
|
||||||
|
|
||||||
File names follow [name,stdout,exitcode] joined by _ pattern. Stdout may be left blank,
|
File names follow [name,stdout,exitcode] joined by _ pattern. Stdout may be left blank,
|
||||||
but exit code must be supplied.
|
but exit code must be supplied.
|
||||||
|
|
||||||
|
## Arm
|
||||||
|
|
||||||
Obviously the arm tests need an arm platform. This may be defined by ARM_HOST,
|
Obviously the arm tests need an arm platform. This may be defined by ARM_HOST,
|
||||||
eg for simulated ARM_HOST=localhost
|
eg for simulated ARM_HOST=localhost
|
||||||
|
|
||||||
@ -16,3 +20,11 @@ Also port and user may be specified with ARM_PORT and ARM_USER , they default to
|
|||||||
2222 and pi if left blank.
|
2222 and pi if left blank.
|
||||||
SSH keys must be set up so no passwords are required (and the users private key may
|
SSH keys must be set up so no passwords are required (and the users private key may
|
||||||
not be password protected)
|
not be password protected)
|
||||||
|
|
||||||
|
## Developing
|
||||||
|
|
||||||
|
Since the Framework always runs all tests, it is a little cumbersome for developing
|
||||||
|
a single new test. Since all get run and it is slow.
|
||||||
|
|
||||||
|
To develop the next test, one can edit test_new.rb . Once it runs on the interpreter,
|
||||||
|
move the changes to a source file and revert test_new changes.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
class Space
|
class Space
|
||||||
def main(arg)
|
def main(arg)
|
||||||
return 2 +2
|
return 2 + 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
8
test/mains/source/simple-class__4.rb
Normal file
8
test/mains/source/simple-class__4.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
class Space
|
||||||
|
def self.simple
|
||||||
|
return 2 + 2
|
||||||
|
end
|
||||||
|
def main(arg)
|
||||||
|
return Space.simple
|
||||||
|
end
|
||||||
|
end
|
@ -1,17 +1,40 @@
|
|||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
|
||||||
|
# The "New" in this TestNew means that this is the place to develop a new test for the mains dir.
|
||||||
|
# If you just pop a file in the source directory, all tests will run. (Well, actually guard does
|
||||||
|
# not pick up changes on that source dir yet, but when you run it manually, all tests run)
|
||||||
|
# This is fine if all is fine. But if all is fine, you are not developing, just playing.
|
||||||
|
# So when you really need to itereate this editing this gives guard auto-run and just of that
|
||||||
|
# one test that you work on.
|
||||||
|
|
||||||
|
# After getting the test to run, copy paste the whole code into a file in source and revert
|
||||||
|
# changes on this file.
|
||||||
|
|
||||||
module Mains
|
module Mains
|
||||||
class TestNew < MiniTest::Test
|
class TestNew < MiniTest::Test
|
||||||
include Risc::Ticker
|
include Risc::Ticker
|
||||||
|
|
||||||
|
def whole_input
|
||||||
|
<<-eos
|
||||||
|
class Space
|
||||||
|
def self.simple
|
||||||
|
return 2 + 2
|
||||||
|
end
|
||||||
|
def main(arg)
|
||||||
|
return Space.simple
|
||||||
|
end
|
||||||
|
end
|
||||||
|
eos
|
||||||
|
end
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@string_input = as_main("a = 37 ; while(a>0) ; a = a - 1 ; end ; return a")
|
@string_input = whole_input
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
def test_chain # max 1011 iterations on 1014 integers (1024 - 10 reserve)
|
def test_chain
|
||||||
run_all
|
run_all
|
||||||
assert_equal ::Integer , get_return.class , " "
|
assert_equal ::Integer , get_return.class , " "
|
||||||
assert_equal 0 , get_return , " "
|
assert_equal 4 , get_return , " "
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user