diff options
| author | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-02 19:07:45 +0000 |
|---|---|---|
| committer | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-02 19:07:45 +0000 |
| commit | 29d4220e9b0323ff28345ff4809c93c6cedfadba (patch) | |
| tree | b474457e24af8955b9ee112a389004916271cfaa /test | |
| parent | 1b8af3b342833ede0ab4085f0e5a2347c27a15c7 (diff) | |
Fix without strscan problems. [ruby_core:17028].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
| -rw-r--r-- | test/erb/test_erb.rb | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/test/erb/test_erb.rb b/test/erb/test_erb.rb index 90b2f7c31f..48bd7b50b9 100644 --- a/test/erb/test_erb.rb +++ b/test/erb/test_erb.rb @@ -44,15 +44,15 @@ class TestERBCore < Test::Unit::TestCase @erb = ERB end - def test_01 - _test_01(nil) - _test_01(0) - _test_01(1) - _test_01(2) - _test_01(3) + def test_core + _test_core(nil) + _test_core(0) + _test_core(1) + _test_core(2) + _test_core(3) end - def _test_01(safe) + def _test_core(safe) erb = @erb.new("hello") assert_equal("hello", erb.result) @@ -157,14 +157,14 @@ EOS assert_equal(ans, erb.result) end - def test_02_safe_04 + def test_safe_04 erb = @erb.new('<%=$SAFE%>', 4) assert_equal('4', erb.result(TOPLEVEL_BINDING.taint)) end class Foo; end - def test_03_def_class + def test_def_class erb = @erb.new('hello') cls = erb.def_class assert_equal(Object, cls.superclass) @@ -177,7 +177,7 @@ EOS assert(cls.new.respond_to?('erb')) end - def test_04_percent + def test_percent src = <<EOS %n = 1 <%= n%> @@ -218,26 +218,24 @@ EOS assert_equal(ans, ERB.new(src, nil, '%').result) end - class Bar; end - - def test_05_def_method - assert(! Bar.new.respond_to?('hello')) - Bar.module_eval do + def test_def_method + klass = Class.new + klass.module_eval do extend ERB::DefMethod fname = File.join(File.dirname(File.expand_path(__FILE__)), 'hello.erb') def_erb_method('hello', fname) end - assert(Bar.new.respond_to?('hello')) + assert(klass.new.respond_to?('hello')) - assert(! Bar.new.respond_to?('hello_world')) + assert(! klass.new.respond_to?('hello_world')) erb = @erb.new('hello, world') - Bar.module_eval do + klass.module_eval do def_erb_method('hello_world', erb) end - assert(Bar.new.respond_to?('hello_world')) + assert(klass.new.respond_to?('hello_world')) end - def test_06_escape + def test_escape src = <<EOS 1.<%% : <%="<%%"%> 2.%%> : <%="%%>"%> @@ -274,7 +272,7 @@ EOS assert_equal(ans, ERB.new(src, nil, '%').result) end - def test_07_keep_lineno + def test_keep_lineno src = <<EOS Hello, % x = "World" @@ -378,7 +376,7 @@ EOS end end - def test_08_explicit + def test_explicit src = <<EOS <% x = %w(hello world) -%> NotSkip <%- y = x -%> NotSkip @@ -411,3 +409,16 @@ EOS assert_equal(ans, ERB.new(src, nil, '-%').result) end end + +class TestERBCoreWOStrScan < TestERBCore + def setup + @save_map = ERB::Compiler::Scanner.instance_variable_get('@scanner_map') + map = {[nil, false]=>ERB::Compiler::SimpleScanner} + ERB::Compiler::Scanner.instance_variable_set('@scanner_map', map) + super + end + + def teardown + ERB::Compiler::Scanner.instance_variable_set('@scanner_map', @save_map) + end +end |
