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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
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
}
assert_equal 'okok', %q{
open("zzz.rb", "w") {|f| f.puts "class ZZZ; def self.ok;:ok;end;end"}
autoload :ZZZ, "./zzz.rb"
t1 = Thread.new {ZZZ.ok}
t2 = Thread.new {ZZZ.ok}
[t1.value, t2.value].join
}
assert_finish 5, %q{
autoload :ZZZ, File.expand_path(__FILE__)
begin
ZZZ
rescue NameError
end
}, '[ruby-core:21696]'
|