1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
assert_equal 'ok', %q{
open("zzz.rb", "w") {|f| f.puts "class ZZZ; def self.ok;:ok;end;end"}
autoload :ZZZ, "./zzz.rb"
ZZZ.ok
}
assert_equal 'ok', %q{
open("zzz.rb", "w") {|f| f.puts "class ZZZ; def self.ok;:ok;end;end"}
autoload :ZZZ, "./zzz.rb"
require "./zzz.rb"
ZZZ.ok
}
assert_equal 'ok', %q{
open("zzz.rb", "w") {|f| f.puts "class ZZZ; def self.ok;:ok;end;end"}
autoload :ZZZ, "./zzz.rb"
proc{$SAFE=4; ZZZ.ok}.call
}
assert_equal 'ok', %q{
open("zzz.rb", "w") {|f| f.puts "class ZZZ; def self.ok;:ok;end;end"}
autoload :ZZZ, "./zzz.rb"
require "./zzz.rb"
proc{$SAFE=4; ZZZ.ok}.call
}
assert_equal 'ok', %q{
open("zzz.rb", "w") {|f| f.puts "class ZZZ; def hoge;:ok;end;end"}
autoload :ZZZ, File.join(Dir.pwd, 'zzz.rb')
module M; end
Thread.new{M.instance_eval('$SAFE=4; ZZZ.new.hoge')}.value
}
assert_equal 'ok', %q{
open("zzz.rb", "w") {|f| f.puts "class ZZZ; def hoge;:ok;end;end"}
autoload :ZZZ, File.join(Dir.pwd, 'zzz.rb')
module M; end
Thread.new{$SAFE=4; M.instance_eval('ZZZ.new.hoge')}.value
}
assert_equal 'ok', %q{
open("zzz.rb", "w") {|f| f.puts "class ZZZ; def hoge;:ok;end;end"}
autoload :ZZZ, File.join(Dir.pwd, 'zzz.rb')
Thread.new{$SAFE=4; eval('ZZZ.new.hoge')}.value
}
assert_equal 'ok', %q{
open("zzz.rb", "w") {|f| f.puts "class ZZZ; def hoge;:ok;end;end"}
autoload :ZZZ, File.join(Dir.pwd, 'zzz.rb')
module M; end
Thread.new{eval('$SAFE=4; ZZZ.new.hoge')}.value
}
|