Skip to content

Commit 0e0ea61

Browse files
committed
Add debug code
1 parent 9641ba8 commit 0e0ea61

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

lib/power_assert/context.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,43 @@
11
module M
2+
# set redefined flag
3+
basic_classes = [
4+
Integer, Float, String, Array, Hash, Symbol, Time, Regexp, NilClass, TrueClass, FalseClass
5+
]
6+
7+
basic_operators = [
8+
:+, :-, :*, :/, :%, :==, :===, :<, :<=, :<<, :[], :[]=, :length, :size,
9+
:empty?, :nil?, :succ, :>, :>=, :!, :!=, :=~, :freeze, :-@, :max, :min,
10+
# :call (it is just used for block call optimization)
11+
:&, :|,
12+
# :default (no specialized instruction for this)
13+
:pack, :include?,
14+
]
15+
16+
basic_classes.each do |klass|
17+
basic_operators.each do |bop|
18+
if klass.public_method_defined?(bop)
19+
refine(klass) do
20+
define_method(bop) {}
21+
end
22+
end
23+
end
24+
end
25+
26+
# bypass check_cfunc
27+
refine BasicObject do
28+
def !
29+
end
30+
31+
def ==
32+
end
33+
end
34+
35+
refine Module do
36+
def ==
37+
end
38+
end
39+
40+
241
refine Class do
342
def new
443
end

0 commit comments

Comments
 (0)