Skip to content

Commit

Permalink
Test case for class re-opening
Browse files Browse the repository at this point in the history
  • Loading branch information
vidarh committed Oct 9, 2014
1 parent 083d0b5 commit 02021ad
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions features/compiler.feature
Expand Up @@ -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
Expand Down
61 changes: 61 additions & 0 deletions features/inputs/redefine.rb
@@ -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
23 changes: 23 additions & 0 deletions features/outputs/redefine.txt
@@ -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.