ruby: add tests

This commit is contained in:
yoff
2025-04-04 16:16:26 +02:00
parent e5fc1b0b00
commit b205fedef4
4 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
def test_basic(x)
y = x #$ Alert
y = x + 2
return y
end
def test_retry
x = 0
begin
if x == 0
raise "error"
end
rescue
x = 2 #$ SPURIOUS: Alert
retry
end
return 42
end
def test_binding
x = 4 #$ SPURIOUS: Alert
return binding
end
class Sup
def m(x)
print(x + 1)
end
end
class Sub < Sup
def m(y)
y = 3 # OK - the call to `super` sees the value of y
super
end
end