From 27a7657842d0c1a44a99b1c83930b1e44f63747b Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 1 Dec 2015 11:55:33 +0200 Subject: [PATCH] add parser and basic test framework that doesnt actually do anything. but WILL, great things, off course --- Gemfile.lock | 3 +++ salama.gemspec | 1 + test/melon/helper.rb | 15 ++++++++++++ test/melon/test_adds.rb | 51 ++++++++++++++++++++++++++++++++++++++++ test/melon/test_all.rb | 5 ++++ test/melon/test_calls.rb | 45 +++++++++++++++++++++++++++++++++++ test/melon/test_hello.rb | 27 +++++++++++++++++++++ test/melon/test_itos.rb | 28 ++++++++++++++++++++++ test/melon/test_loop.rb | 17 ++++++++++++++ 9 files changed, 192 insertions(+) create mode 100644 test/melon/helper.rb create mode 100644 test/melon/test_adds.rb create mode 100644 test/melon/test_all.rb create mode 100644 test/melon/test_calls.rb create mode 100644 test/melon/test_hello.rb create mode 100644 test/melon/test_itos.rb create mode 100644 test/melon/test_loop.rb diff --git a/Gemfile.lock b/Gemfile.lock index 7a8aefee..15d5bba8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,6 +28,7 @@ PATH remote: . specs: salama (0.5.0) + parser (~> 2.2.0) salama-object-file (~> 0.3) soml-parser (~> 0.5) @@ -73,6 +74,8 @@ GEM notiffany (0.0.8) nenv (~> 0.1) shellany (~> 0.0) + parser (2.2.3.0) + ast (>= 1.1, < 3.0) parslet (1.7.1) blankslate (>= 2.0, <= 4.0) pry (0.10.2) diff --git a/salama.gemspec b/salama.gemspec index beeb7738..22af4e4e 100644 --- a/salama.gemspec +++ b/salama.gemspec @@ -14,5 +14,6 @@ Gem::Specification.new do |s| s.summary = 'Salama is a native object vm without any c, one day possibly a ruby vm' s.add_dependency "soml-parser" , "~> 0.5" + s.add_dependency "parser" , "~> 2.2.0" s.add_dependency "salama-object-file" , "~> 0.3" end diff --git a/test/melon/helper.rb b/test/melon/helper.rb new file mode 100644 index 00000000..a3648b9f --- /dev/null +++ b/test/melon/helper.rb @@ -0,0 +1,15 @@ +require_relative '../helper' +require "register/interpreter" +require "parser/ruby22" + +module MelonTests + + def setup + @parser = Parser::Ruby22 + end + + def check + assert true + puts @parser.parse @string_input + end +end diff --git a/test/melon/test_adds.rb b/test/melon/test_adds.rb new file mode 100644 index 00000000..bed6f394 --- /dev/null +++ b/test/melon/test_adds.rb @@ -0,0 +1,51 @@ +require_relative 'helper' + +class TestRubyAdds < MiniTest::Test + include MelonTests + + def test_ruby_adds + @string_input = < 0) do + fibo(40) + counter -= 1 + end +HERE + @length = 37 + @stdout = "Hello Raisa, I am salama" + check + end +end diff --git a/test/melon/test_all.rb b/test/melon/test_all.rb new file mode 100644 index 00000000..020fc5a6 --- /dev/null +++ b/test/melon/test_all.rb @@ -0,0 +1,5 @@ +require_relative "test_loop" +require_relative "test_itos" +require_relative "test_calls" +require_relative "test_adds" +require_relative "test_hello" diff --git a/test/melon/test_calls.rb b/test/melon/test_calls.rb new file mode 100644 index 00000000..13d84493 --- /dev/null +++ b/test/melon/test_calls.rb @@ -0,0 +1,45 @@ +require_relative 'helper' + +class TestRubyCalls < MiniTest::Test + include MelonTests + + def test_ruby_calls + @string_input = < 0) do + fibo_r(20) + counter -= 1 + end +HERE + @length = 37 + @stdout = "" + check + end +end diff --git a/test/melon/test_hello.rb b/test/melon/test_hello.rb new file mode 100644 index 00000000..52d8e279 --- /dev/null +++ b/test/melon/test_hello.rb @@ -0,0 +1,27 @@ +require_relative 'helper' + +class TestRubyHello < MiniTest::Test + include MelonTests + + def test_ruby_hello + @string_input = < 0) do + puts "Hello there" + STDOUT.flush + counter = counter - 1 + end +HERE + @length = 37 + @stdout = "Hello Raisa, I am salama" + check + end +end diff --git a/test/melon/test_itos.rb b/test/melon/test_itos.rb new file mode 100644 index 00000000..b1c6112a --- /dev/null +++ b/test/melon/test_itos.rb @@ -0,0 +1,28 @@ +require_relative 'helper' + +class TestRubyItos < MiniTest::Test + include MelonTests + + def test_ruby_itos + @string_input = < 0) do + str = counter.to_s + counter = counter - 1 + end + str +HERE + @length = 37 + @stdout = "Hello Raisa, I am salama" + check + end +end diff --git a/test/melon/test_loop.rb b/test/melon/test_loop.rb new file mode 100644 index 00000000..4e736cab --- /dev/null +++ b/test/melon/test_loop.rb @@ -0,0 +1,17 @@ +require_relative 'helper' + +class TestRubyLoop < MiniTest::Test + include MelonTests + + def test_ruby_loop + @string_input = < 0) do + counter -= 1 +end +HERE + @stdout = "Hello there" + check + end + +end