Permalink
Browse files

Test case for class re-opening

  • Loading branch information...
vidarh committed Oct 9, 2014
1 parent 083d0b5 commit 02021ade0f20b2fed05fe35b484fea719e929540
Showing with 85 additions and 0 deletions.
  1. +1 −0 features/compiler.feature
  2. +61 −0 features/inputs/redefine.rb
  3. +23 −0 features/outputs/redefine.txt
@@ -46,6 +46,7 @@ Feature: Compiler
| inputs/defaultargs.rb | outputs/defaultargs.txt | Default arguments to methods |
| inputs/nil.rb | outputs/nil.txt | Basic checks of "nil" |
| inputs/typed_and.rb | outputs/typed_and.txt | Regression check for and/or with typing |
| inputs/redefine.rb | outputs/redefine.txt | Re-opening classes |
@logic
Scenario Outline: Running programs
@@ -0,0 +1,61 @@
class Foo
def hello
puts "hello"
end
def world
puts "world"
end
end
# Bar does not override anything, so it should keep acting like Foo.
class Bar < Foo
end
# Baz overrides, so when Foo#hello is overriden, Baz#hello should remain
# overriden
class Baz < Foo
def hello
puts "crazy"
end
end
puts "Foo"
f = Foo.new
f.hello
f.world
puts
puts "Bar"
b = Bar.new
b.hello
b.world
puts
puts "Baz"
z = Baz.new
z.hello
z.world
puts
class Foo
def hello
puts "goodbye cruel"
end
end
puts "Foo:"
f.hello
f.world
puts
puts "Bar should be identical to Foo:"
b.hello
b.world
puts
puts "Baz overrode Foo#hello, so should be identical to Baz above"
z.hello
z.world
@@ -0,0 +1,23 @@
Foo
hello
world
Bar
hello
world
Baz
crazy
world
Foo:
goodbye cruel
world
Bar should be identical to Foo:
goodbye cruel
world
Baz overrode Foo#hello, so should be identical to Baz above
crazy
world

0 comments on commit 02021ad

Please sign in to comment.