Skip to content

Commit 3d80eda

Browse files
committed
Add specs for aliasing global variables
1 parent 6b35ced commit 3d80eda

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spec/ruby/language/alias_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,15 @@ def test_with_check(*args)
244244
}
245245
end
246246
end
247+
248+
describe "The alias keyword" do
249+
it "can create a new global variable, synonym of the original" do
250+
code = '$a = 1; alias $b $a; p [$a, $b]; $b = 2; p [$a, $b]'
251+
ruby_exe(code).should == "[1, 1]\n[2, 2]\n"
252+
end
253+
254+
it "can override an existing global variable and make them synonyms" do
255+
code = '$a = 1; $b = 2; alias $b $a; p [$a, $b]; $b = 3; p [$a, $b]'
256+
ruby_exe(code).should == "[1, 1]\n[3, 3]\n"
257+
end
258+
end

0 commit comments

Comments
 (0)