From 437733f187b184f734ac6f71a4949b727a7467a6 Mon Sep 17 00:00:00 2001 From: makoto kuwata Date: Sun, 20 Mar 2011 00:44:47 +0900 Subject: [enhance] modify test scripts to support Rubinius --- test/test-main.rb | 35 +++++++++++++++++++++++++++++++++-- test/test-users-guide.rb | 10 +++++++++- 2 files changed, 42 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/test-main.rb b/test/test-main.rb index 3e78cfc..0e63229 100644 --- a/test/test-main.rb +++ b/test/test-main.rb @@ -7,6 +7,7 @@ require "#{File.dirname(__FILE__)}/test.rb" require 'tempfile' +require 'fileutils' require 'erubis/main' @@ -25,6 +26,17 @@ class StringWriter < String def flush(*args) # pass end + def puts(arg) + case arg + when Array + arg.each do |item| + self << item << "\n" + end + else + self << arg.to_s + self << "\n" unless arg =~ /\n$/ + end + end end class Erubis::Main @@ -260,6 +272,17 @@ END END errmsgs << <<'END' 7: syntax error, unexpected $end, expecting keyword_end +END + elsif rubinius? + errmsgs << <<'END' +3: expecting ')' + _buf << '
  • '; _buf << ( item[:name]] ).to_s; _buf << '
  • + ^ +END + errmsgs << <<'END' +7: missing 'end' for 'for' started on line 2 +_buf.to_s + ^ END else errmsgs << <<'END' @@ -281,6 +304,10 @@ END @input = inputs[i] @expected = "tmp.test_syntax2:#{errmsgs[i]}" @options = '-z' + if rubinius? + @expected.sub! /unexpected kEND/, 'unexpected keyword_end' + @expected.sub! /expecting kEND/, 'expecting keyword_end' + end _test() end # @@ -295,6 +322,10 @@ END @expected << "#{filenames[i]}:#{errmsgs[i]}" @options << " #{filenames[i]}" end + if rubinius? + @expected.sub! /unexpected kEND/, 'unexpected keyword_end' + @expected.sub! /expecting kEND/, 'expecting keyword_end' + end _test() ensure (0...max).each do |i| @@ -566,7 +597,7 @@ END _test() ensure File.unlink filename if test(?f, filename) - Dir.rmdir dir if test(?d, dir) + FileUtils.rm_r dir if test(?d, dir) end end @@ -592,7 +623,7 @@ END _test() ensure File.unlink filename if test(?f, filename) - Dir.rmdir dir if test(?d, dir) + FileUtils.rm_r dir if test(?d, dir) end end diff --git a/test/test-users-guide.rb b/test/test-users-guide.rb index f830665..2687a83 100644 --- a/test/test-users-guide.rb +++ b/test/test-users-guide.rb @@ -28,13 +28,21 @@ class KwarkUsersGuideTest < Test::Unit::TestCase s =~ /\A\$ (.*?)\n/ command = $1 expected = $' - ruby19 do + if ruby19? case @name when 'test_main_program1_result' expected.sub!('["eruby", "items", "x", "_buf"]', '[:_buf, :eruby, :items, :x]') when 'test_main_program2_result' expected.sub!('["_context", "x", "_buf"]', '[:_buf, :x, :_context]') end + elsif rubinius? + command.sub!(/^ruby\b/, 'rbx') + case @name + when 'test_main_program1_result' + expected.sub!('["eruby", "items", "x", "_buf"]', '["_buf", "eruby", "items", "x"]') + when 'test_main_program2_result' + expected.sub!('["_context", "x", "_buf"]', '["_buf", "x", "_context"]') + end end result = `#{command}` assert_text_equal(expected, result) -- cgit v1.2.1