Skip to content

Commit

Permalink
refactoring testing interface
Browse files Browse the repository at this point in the history
  • Loading branch information
katsyoshi committed Sep 5, 2023
1 parent 654e55c commit 2f7fbf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
1 change: 1 addition & 0 deletions lib/vaporware/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def self.compile(source, compiler: "gcc", dest: "tmp", debug: false, compiler_op
s.compile(compiler:, compiler_options:)
obj_file = s.assemble(input: _precompile, assembler: "as", debug:)
s.link(obj_file)
File.delete(_precompile) if debug
end

def initialize(source, _precompile: "tmp.s", debug: false, shared: false)
Expand Down
18 changes: 6 additions & 12 deletions test/test_vaporware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ class VaporwareTest < Test::Unit::TestCase
def tear_down = File.delete("tmp") rescue File.delete(@generated)
def test_sample_plus
@file = "sample/plus.rb"
@vaporware = Vaporware::Compiler.new(@file)
@vaporware.compile
@vaporware = Vaporware::Compiler.compile(@file)
IO.popen("./tmp").close
exit_code, handle_code = check_process($?.to_i)
assert_equal(9, exit_code)
Expand All @@ -15,8 +14,7 @@ def test_sample_plus

def test_sample_variable
@file = "sample/variable.rb"
@vaporware = Vaporware::Compiler.new(@file)
@vaporware.compile
@vaporware = Vaporware::Compiler.compile(@file)
IO.popen("./tmp").close
exit_code, handle_code = check_process($?.to_i)
assert_equal(1, exit_code)
Expand All @@ -25,8 +23,7 @@ def test_sample_variable

def test_sample_if
@file = "sample/if.rb"
@vaporware = Vaporware::Compiler.new(@file)
@vaporware.compile
@vaporware = Vaporware::Compiler.compile(@file)
IO.popen("./tmp").close
exit_code, handle_code = check_process($?.to_i)
assert_equal(1, exit_code)
Expand All @@ -35,8 +32,7 @@ def test_sample_if

def test_sample_else
@file = "sample/else.rb"
@vaporware = Vaporware::Compiler.new(@file)
@vaporware.compile
@vaporware = Vaporware::Compiler.compile(@file)
IO.popen("./tmp").close
exit_code, handle_code = check_process($?.to_i)
assert_equal(2, exit_code)
Expand All @@ -45,8 +41,7 @@ def test_sample_else

def test_sample_while
@file = "sample/while.rb"
@vaporware = Vaporware::Compiler.new(@file)
@vaporware.compile
@vaporware = Vaporware::Compiler.compile(@file)
IO.popen("./tmp").close
exit_code, handle_code = check_process($?.to_i)
assert_equal(55, exit_code)
Expand All @@ -56,8 +51,7 @@ def test_sample_while
def test_sample_call_method
@generated = "libtmp.so"
@file = "sample/method.rb"
@vaporware = Vaporware::Compiler.new(@file, shared: true)
@vaporware.compile
@vaporware = Vaporware::Compiler.compile(@file, shared: true)
require './sample/fiddle.rb'
assert_equal(10, X.aibo)
end
Expand Down

0 comments on commit 2f7fbf4

Please sign in to comment.