This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
covers 'facets/binding/caller'
|
||||
|
||||
test_case Binding do
|
||||
|
||||
a = 1
|
||||
b = 2
|
||||
x = "hello"
|
||||
|
||||
bind = binding
|
||||
line = __LINE__ # the line number must be updated if it moves
|
||||
file = __FILE__ # why does it equal basename only?
|
||||
|
||||
method :__LINE__ do
|
||||
test do
|
||||
bind.__LINE__.assert == line - 1
|
||||
end
|
||||
end
|
||||
|
||||
method :__FILE__ do
|
||||
test do
|
||||
bind.__FILE__.assert == file
|
||||
end
|
||||
end
|
||||
|
||||
method :__DIR__ do
|
||||
test do
|
||||
bind.__DIR__.assert == File.dirname(file)
|
||||
end
|
||||
end
|
||||
|
||||
method :callstack do
|
||||
test do
|
||||
bind.callstack.assert.is_a?(Array)
|
||||
end
|
||||
end
|
||||
|
||||
method :call_stack do
|
||||
test do
|
||||
bind.call_stack.assert.is_a?(Array)
|
||||
end
|
||||
end
|
||||
|
||||
method :caller do
|
||||
test do
|
||||
Exception.refute.raised? do
|
||||
bind.caller
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
method :__callee__ do
|
||||
test do
|
||||
alternate.__callee__.assert == :alternate
|
||||
end
|
||||
end
|
||||
|
||||
method :__method__ do
|
||||
test do
|
||||
alternate.__method__.assert == :alternate
|
||||
end
|
||||
end
|
||||
|
||||
# helper method
|
||||
def alternate
|
||||
binding
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
covers 'facets/binding/defined'
|
||||
|
||||
test_case Binding do
|
||||
|
||||
a = 1
|
||||
b = 2
|
||||
x = "hello"
|
||||
|
||||
bind = binding
|
||||
|
||||
method :defined? do
|
||||
test do
|
||||
bind.assert.defined?("x")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
covers 'facets/binding/op'
|
||||
|
||||
test_case Binding do
|
||||
|
||||
a = 1
|
||||
b = 2
|
||||
x = "hello"
|
||||
|
||||
bind = binding
|
||||
|
||||
method :[] do
|
||||
test do
|
||||
bind["x"].assert == "hello"
|
||||
end
|
||||
end
|
||||
|
||||
method :[]= do
|
||||
test do
|
||||
bind["x"] = "goodbye"
|
||||
bind["x"].assert == "goodbye"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
covers 'facets/binding/self'
|
||||
|
||||
test_case Binding do
|
||||
|
||||
bind = binding
|
||||
this = self
|
||||
|
||||
method :self do
|
||||
|
||||
test do
|
||||
bind.self == this
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user