HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/src/ruby-3.0.2/spec/ruby/language/END_spec.rb
require_relative '../spec_helper'

describe "The END keyword" do
  it "runs only once for multiple calls" do
    ruby_exe("10.times { END { puts 'foo' }; } ").should == "foo\n"
  end

  it "runs last in a given code unit" do
    ruby_exe("END { puts 'bar' }; puts'foo'; ").should == "foo\nbar\n"
  end

  it "runs multiple ends in LIFO order" do
    ruby_exe("END { puts 'foo' }; END { puts 'bar' }").should == "bar\nfoo\n"
  end
end