rubyx/test/mains
Torsten e8111c259b fix last tests that required faked returns 2020-03-28 19:46:07 +02:00
..
source Removing preloads from mains tests 2019-09-24 22:05:38 +03:00
README.md fix last tests that required faked returns 2020-03-28 19:46:07 +02:00
helper.rb add decent method to get the programs return to interpreter 2020-03-28 18:39:49 +02:00
test_arm.rb arm tests back on line 2020-03-26 20:30:47 +02:00
test_assign.rb better framework for running arm test 2020-03-26 20:28:59 +02:00
test_calling.rb moving more tests to arm 2020-03-27 20:18:14 +02:00
test_class.rb make class method tests arm tests 2020-03-28 09:36:16 +02:00
test_conditional.rb move conditional test to arm 2020-03-28 11:51:16 +02:00
test_int_cmp.rb adding integer compare tests and fixing returns 2020-03-28 18:41:59 +02:00
test_int_math.rb fix last tests that required faked returns 2020-03-28 19:46:07 +02:00
test_interpreted.rb Removing preloads from mains tests 2019-09-24 22:05:38 +03:00
test_new.rb arm tests back on line 2020-03-26 20:30:47 +02:00
test_while.rb fix last tests that required faked returns 2020-03-28 19:46:07 +02:00

README.md

Mains testing

Test methods by their output and exit codes (return, since it is the main).

Every test here is tested first as an Interpreter test, and then as binary (arm).

Setup and assert

The setup require the @input variable to hold the code. This is usually renerated with as_main or similar helper.

The @preload may be set to load any of the Macros, so one can actually use methods. Otherwise the only methods are the ones you code

The assert_result takes the exit code and std out. It runs both interpreter and arm, in that order.

Interpreter

The interpreter is for the most part like another platform. Everything up to the creation of binaries is the same. The Linker object get's passed to the Interpreter which runs the code to the end, and returns return code and stdout.

If this passes, arm is run.

Arm

Arm is actually only run if:

  • you set TEST_ALL (as is done in test/test_all)
  • you set TEST_ARM

AND it requires that you have qemu set up correctly. But given all that, it:

  • creates a binary from the code (mains.o), which is linked to a.out
  • runs the binary
  • captures return code and stdout and returns

Obviously Interpreter AND Arm need to return same codes, the one the assert specifies.

Status

I have moved most of the risc/interpreter code here, which means we now have over 50 binary tests.

Next i will recreate the file based tests in a better way to integrate with the current style.