opal 0.3.16 → 0.3.17
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +8 -7
- data/README.md +21 -13
- data/Rakefile +64 -78
- data/bin/opal +18 -29
- data/core/alpha.rb +2 -9
- data/core/array.rb +106 -50
- data/core/basic_object.rb +10 -8
- data/core/boolean.rb +2 -0
- data/core/class.rb +25 -13
- data/core/comparable.rb +6 -6
- data/core/enumerable.rb +90 -94
- data/core/enumerator.rb +3 -3
- data/core/hash.rb +86 -46
- data/core/kernel.rb +55 -39
- data/core/load_order +2 -5
- data/core/match_data.rb +1 -1
- data/core/module.rb +45 -20
- data/core/nil_class.rb +6 -2
- data/core/numeric.rb +20 -10
- data/core/proc.rb +2 -2
- data/core/range.rb +72 -13
- data/core/regexp.rb +5 -3
- data/core/runtime.js +228 -287
- data/core/string.rb +345 -37
- data/core/top_self.rb +1 -1
- data/lib/opal.rb +13 -91
- data/lib/opal/builder.rb +47 -120
- data/lib/opal/builder_task.rb +74 -0
- data/lib/opal/{parser/grammar.rb → grammar.rb} +1094 -1083
- data/lib/opal/{parser/grammar.y → grammar.y} +7 -0
- data/lib/opal/{parser/lexer.rb → lexer.rb} +32 -11
- data/lib/opal/{parser/parser.rb → parser.rb} +232 -238
- data/lib/opal/{parser/scope.rb → scope.rb} +72 -9
- data/lib/opal/version.rb +2 -3
- data/opal.gemspec +1 -2
- data/{core_spec → spec}/core/array/allocate_spec.rb +1 -3
- data/{core_spec → spec}/core/array/append_spec.rb +1 -4
- data/{core_spec → spec}/core/array/assoc_spec.rb +1 -4
- data/{core_spec → spec}/core/array/at_spec.rb +1 -3
- data/{core_spec → spec}/core/array/clear_spec.rb +1 -3
- data/spec/core/array/clone_spec.rb +15 -0
- data/{core_spec/core/array/shared/collect.rb → spec/core/array/collect_spec.rb} +1 -1
- data/{core_spec → spec}/core/array/compact_spec.rb +1 -3
- data/{core_spec → spec}/core/array/concat_spec.rb +1 -3
- data/{core_spec → spec}/core/array/constructor_spec.rb +9 -3
- data/{core_spec → spec}/core/array/count_spec.rb +1 -3
- data/{core_spec → spec}/core/array/delete_at_spec.rb +1 -4
- data/{core_spec → spec}/core/array/delete_if_spec.rb +1 -4
- data/{core_spec → spec}/core/array/delete_spec.rb +1 -4
- data/{core_spec → spec}/core/array/each_index_spec.rb +1 -4
- data/{core_spec → spec}/core/array/each_spec.rb +1 -4
- data/{core_spec → spec}/core/array/element_reference_spec.rb +74 -4
- data/{core_spec → spec}/core/array/empty_spec.rb +1 -4
- data/{core_spec/core/array/shared/eql.rb → spec/core/array/eql_spec.rb} +1 -1
- data/{core_spec → spec}/core/array/fetch_spec.rb +1 -4
- data/{core_spec → spec}/core/array/first_spec.rb +1 -3
- data/{core_spec → spec}/core/array/flatten_spec.rb +1 -3
- data/{core_spec → spec}/core/array/include_spec.rb +1 -3
- data/{core_spec → spec}/core/array/insert_spec.rb +1 -4
- data/{core_spec → spec}/core/array/last_spec.rb +1 -4
- data/{core_spec/core/array/shared/length.rb → spec/core/array/length_spec.rb} +1 -1
- data/spec/core/array/map_spec.rb +53 -0
- data/{core_spec → spec}/core/array/plus_spec.rb +1 -4
- data/{core_spec → spec}/core/array/pop_spec.rb +1 -4
- data/{core_spec → spec}/core/array/push_spec.rb +1 -4
- data/{core_spec → spec}/core/array/rassoc_spec.rb +1 -4
- data/{core_spec → spec}/core/array/reject_spec.rb +1 -4
- data/{core_spec/core/array/shared/replace.rb → spec/core/array/replace_spec.rb} +1 -1
- data/{core_spec → spec}/core/array/reverse_each_spec.rb +1 -4
- data/{core_spec → spec}/core/array/reverse_spec.rb +1 -4
- data/spec/core/array/size_spec.rb +6 -0
- data/spec/core/array/to_ary_spec.rb +6 -0
- data/spec/core/array/uniq_spec.rb +22 -0
- data/spec/core/array/zip_spec.rb +20 -0
- data/{core_spec → spec}/core/class/new_spec.rb +1 -4
- data/{core_spec → spec}/core/enumerable/all_spec.rb +1 -4
- data/{core_spec → spec}/core/enumerable/any_spec.rb +1 -4
- data/{core_spec/core/enumerable/shared/collect.rb → spec/core/enumerable/collect_spec.rb} +1 -1
- data/{core_spec → spec}/core/enumerable/count_spec.rb +2 -5
- data/{core_spec → spec}/core/enumerable/fixtures/classes.rb +1 -2
- data/{core_spec → spec}/core/false/and_spec.rb +1 -3
- data/{core_spec → spec}/core/false/inspect_spec.rb +1 -3
- data/{core_spec → spec}/core/false/or_spec.rb +1 -3
- data/{core_spec → spec}/core/false/to_s_spec.rb +1 -3
- data/{core_spec → spec}/core/false/xor_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/allocate_spec.rb +1 -3
- data/spec/core/hash/assoc_spec.rb +25 -0
- data/{core_spec → spec}/core/hash/clear_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/clone_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/default_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/delete_if_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/element_reference_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/element_set_spec.rb +1 -3
- data/spec/core/hash/merge_spec.rb +37 -0
- data/{core_spec → spec}/core/hash/new_spec.rb +1 -3
- data/{core_spec → spec}/core/matchdata/to_a_spec.rb +1 -3
- data/{core_spec → spec}/core/nil/and_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/inspect_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/nil_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/or_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/to_a_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/to_f_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/to_i_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/to_s_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/xor_spec.rb +1 -4
- data/{core_spec → spec}/core/numeric/equal_value_spec.rb +1 -3
- data/{core_spec → spec}/core/regexp/match_spec.rb +10 -3
- data/{core_spec → spec}/core/symbol/to_proc_spec.rb +1 -3
- data/{core_spec → spec}/core/true/and_spec.rb +1 -3
- data/{core_spec → spec}/core/true/inspect_spec.rb +1 -3
- data/{core_spec → spec}/core/true/or_spec.rb +1 -3
- data/{core_spec → spec}/core/true/to_s_spec.rb +1 -3
- data/{core_spec → spec}/core/true/xor_spec.rb +1 -3
- data/spec/index.html +11 -0
- data/{core_spec → spec}/language/alias_spec.rb +1 -3
- data/{core_spec → spec}/language/and_spec.rb +1 -4
- data/{core_spec → spec}/language/array_spec.rb +1 -4
- data/{core_spec → spec}/language/block_spec.rb +20 -3
- data/{core_spec → spec}/language/break_spec.rb +40 -3
- data/{core_spec → spec}/language/case_spec.rb +1 -4
- data/{core_spec → spec}/language/defined_spec.rb +9 -3
- data/{core_spec → spec}/language/ensure_spec.rb +38 -3
- data/{core_spec → spec}/language/hash_spec.rb +1 -3
- data/{core_spec → spec}/language/if_spec.rb +1 -4
- data/{core_spec → spec}/language/loop_spec.rb +1 -3
- data/spec/language/metaclass_spec.rb +13 -0
- data/{core_spec → spec}/language/next_spec.rb +47 -3
- data/{core_spec → spec}/language/or_spec.rb +1 -4
- data/{core_spec → spec}/language/predefined_spec.rb +1 -3
- data/{core_spec/language/regexp/interpolation_spec.rb → spec/language/regexp_spec.rb} +6 -3
- data/{core_spec → spec}/language/send_spec.rb +38 -4
- data/spec/language/singleton_class_spec.rb +31 -0
- data/spec/language/super_spec.rb +188 -0
- data/{core_spec → spec}/language/symbol_spec.rb +1 -3
- data/{core_spec → spec}/language/undef_spec.rb +1 -3
- data/{core_spec → spec}/language/unless_spec.rb +1 -4
- data/{core_spec → spec}/language/until_spec.rb +1 -3
- data/{core_spec → spec}/language/variables_spec.rb +1 -3
- data/{core_spec → spec}/language/while_spec.rb +1 -3
- data/{spec → test}/builder/build_source_spec.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/adam.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/bar/a.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/bar/wow/b.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/bar/wow/cow/c.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/beynon.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/charles.js +0 -0
- data/{spec → test}/builder/fixtures/build_source/foo/a.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/foo/b.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/foo/x.js +0 -0
- data/{spec → test}/builder/fixtures/build_source/foo/y.js +0 -0
- data/{spec → test}/grammar/alias_spec.rb +0 -0
- data/{spec → test}/grammar/and_spec.rb +0 -0
- data/{spec → test}/grammar/array_spec.rb +0 -0
- data/{spec → test}/grammar/attrasgn_spec.rb +0 -0
- data/{spec → test}/grammar/begin_spec.rb +0 -0
- data/{spec → test}/grammar/block_spec.rb +0 -0
- data/{spec → test}/grammar/break_spec.rb +0 -0
- data/{spec → test}/grammar/call_spec.rb +0 -0
- data/{spec → test}/grammar/class_spec.rb +0 -0
- data/{spec → test}/grammar/const_spec.rb +0 -0
- data/{spec → test}/grammar/cvar_spec.rb +0 -0
- data/{spec → test}/grammar/def_spec.rb +0 -0
- data/{spec → test}/grammar/false_spec.rb +0 -0
- data/{spec → test}/grammar/file_spec.rb +0 -0
- data/{spec → test}/grammar/gvar_spec.rb +0 -0
- data/{spec → test}/grammar/hash_spec.rb +0 -0
- data/{spec → test}/grammar/iasgn_spec.rb +0 -0
- data/{spec → test}/grammar/if_spec.rb +0 -0
- data/{spec → test}/grammar/iter_spec.rb +0 -0
- data/{spec → test}/grammar/ivar_spec.rb +0 -0
- data/{spec → test}/grammar/lasgn_spec.rb +0 -0
- data/{spec → test}/grammar/line_spec.rb +0 -0
- data/{spec → test}/grammar/lvar_spec.rb +0 -0
- data/{spec → test}/grammar/masgn_spec.rb +0 -0
- data/{spec → test}/grammar/module_spec.rb +0 -0
- data/{spec → test}/grammar/nil_spec.rb +0 -0
- data/{spec → test}/grammar/not_spec.rb +0 -0
- data/{spec → test}/grammar/op_asgn1_spec.rb +0 -0
- data/{spec → test}/grammar/op_asgn2_spec.rb +0 -0
- data/{spec → test}/grammar/or_spec.rb +0 -0
- data/{spec → test}/grammar/return_spec.rb +0 -0
- data/{spec → test}/grammar/sclass_spec.rb +0 -0
- data/{spec → test}/grammar/self_spec.rb +0 -0
- data/{spec → test}/grammar/str_spec.rb +0 -0
- data/{spec → test}/grammar/super_spec.rb +0 -0
- data/{spec → test}/grammar/true_spec.rb +0 -0
- data/{spec → test}/grammar/undef_spec.rb +0 -0
- data/{spec → test}/grammar/unless_spec.rb +0 -0
- data/{spec → test}/grammar/while_spec.rb +0 -0
- data/{spec → test}/grammar/xstr_spec.rb +0 -0
- data/{spec → test}/grammar/yield_spec.rb +0 -0
- data/{spec → test}/spec_helper.rb +0 -0
- metadata +330 -264
- data/core/debug.js +0 -59
- data/core/debug.rb +0 -35
- data/core/dir.rb +0 -90
- data/core/file.rb +0 -83
- data/core/gemlib.rb +0 -30
- data/core/io.rb +0 -44
- data/core_spec/README.md +0 -34
- data/core_spec/core/array/collect_spec.rb +0 -3
- data/core_spec/core/array/element_set_spec.rb +0 -7
- data/core_spec/core/array/eql_spec.rb +0 -3
- data/core_spec/core/array/equal_value_spec.rb +0 -3
- data/core_spec/core/array/fixtures/classes.rb +0 -8
- data/core_spec/core/array/length_spec.rb +0 -3
- data/core_spec/core/array/map_spec.rb +0 -3
- data/core_spec/core/array/replace_spec.rb +0 -3
- data/core_spec/core/enumerable/collect_spec.rb +0 -3
- data/core_spec/core/enumerable/detect_spec.rb +0 -3
- data/core_spec/core/enumerable/find_spec.rb +0 -3
- data/core_spec/core/enumerable/first_spec.rb +0 -3
- data/core_spec/core/enumerable/shared/entries.rb +0 -7
- data/core_spec/core/enumerable/shared/find.rb +0 -49
- data/core_spec/core/enumerable/shared/take.rb +0 -31
- data/core_spec/core/enumerable/to_a_spec.rb +0 -7
- data/core_spec/core/hash/assoc_spec.rb +0 -29
- data/core_spec/core/object/is_a_spec.rb +0 -2
- data/core_spec/core/object/shared/kind_of.rb +0 -0
- data/core_spec/core/regexp/shared/match.rb +0 -11
- data/core_spec/language/fixtures/block.rb +0 -19
- data/core_spec/language/fixtures/break.rb +0 -39
- data/core_spec/language/fixtures/defined.rb +0 -9
- data/core_spec/language/fixtures/ensure.rb +0 -37
- data/core_spec/language/fixtures/next.rb +0 -46
- data/core_spec/language/fixtures/send.rb +0 -36
- data/core_spec/language/fixtures/super.rb +0 -43
- data/core_spec/language/regexp_spec.rb +0 -7
- data/core_spec/language/string_spec.rb +0 -4
- data/core_spec/language/super_spec.rb +0 -18
- data/core_spec/language/versions/hash_1.9.rb +0 -20
- data/core_spec/opal/opal/defined_spec.rb +0 -15
- data/core_spec/opal/opal/function_spec.rb +0 -11
- data/core_spec/opal/opal/native_spec.rb +0 -16
- data/core_spec/opal/opal/null_spec.rb +0 -10
- data/core_spec/opal/opal/number_spec.rb +0 -11
- data/core_spec/opal/opal/object_spec.rb +0 -16
- data/core_spec/opal/opal/string_spec.rb +0 -11
- data/core_spec/opal/opal/typeof_spec.rb +0 -9
- data/core_spec/opal/opal/undefined_spec.rb +0 -10
- data/core_spec/opal/true/case_compare_spec.rb +0 -12
- data/core_spec/opal/true/class_spec.rb +0 -10
- data/core_spec/release_runner.html +0 -17
- data/core_spec/runner.html +0 -16
- data/core_spec/spec_helper.rb +0 -23
- data/lib/opal/context.rb +0 -269
- data/lib/opal/dependency_builder.rb +0 -133
- data/lib/opal/environment.rb +0 -87
- data/lib/opal/parser/sexp.rb +0 -17
@@ -1,7 +0,0 @@
|
|
1
|
-
#describe :enumerable_entries, :shared => true do
|
2
|
-
describe :enumerable_entires do
|
3
|
-
it "returns an array containing the elements" do
|
4
|
-
numerous = EnumerableSpecs::Numerous.new(1, nil, 'a', 2, false, true)
|
5
|
-
numerous.to_a.should == [1, nil, "a", 2, false, true]
|
6
|
-
end
|
7
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
describe "Enumerable#find" do
|
2
|
-
# #detect and #find are aliases, so we only need one function
|
3
|
-
before :each do
|
4
|
-
ScratchPad.record []
|
5
|
-
@elements = [2, 4, 6, 8, 10]
|
6
|
-
@numerous = EnumerableSpecs::Numerous.new(*@elements)
|
7
|
-
@empty = []
|
8
|
-
end
|
9
|
-
|
10
|
-
it "passes each entry in enum to block while block when block is false" do
|
11
|
-
visited_elements = []
|
12
|
-
@numerous.find do |element|
|
13
|
-
visited_elements << element
|
14
|
-
false
|
15
|
-
end
|
16
|
-
visited_elements.should == @elements
|
17
|
-
end
|
18
|
-
|
19
|
-
it "returns nil when the block is false and there is no ifnore proc given" do
|
20
|
-
@numerous.find {|e| false }.should == nil
|
21
|
-
end
|
22
|
-
|
23
|
-
it "returns the first element for which the block is not false" do
|
24
|
-
@elements.each do |element|
|
25
|
-
@numerous.find {|e| e > element - 1 }.should == element
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "returns the value of the ifnone proc if the block is false" do
|
30
|
-
fail_proc = lambda { "cheeseburgers" }
|
31
|
-
@numerous.find(fail_proc) { |e| false }.should == "cheeseburgers"
|
32
|
-
end
|
33
|
-
|
34
|
-
it "doesn't call the ifnone proc if an element is found" do
|
35
|
-
fail_proc = lambda { raise "This shouldn't have been called" }
|
36
|
-
@numerous.find(fail_proc) {|e| e == @elements.first }.should == 2
|
37
|
-
end
|
38
|
-
|
39
|
-
it "calls the ifnone proc only once when the block is false" do
|
40
|
-
times = 0
|
41
|
-
fail_proc = lambda { times += 1; raise if times > 1; "cheeseburgers" }
|
42
|
-
@numerous.find(fail_proc) {|e| false }.should == "cheeseburgers"
|
43
|
-
end
|
44
|
-
|
45
|
-
it "calls the ifnone proc when there are no elements" do
|
46
|
-
fail_proc = lambda { "yay" }
|
47
|
-
@empty.find(fail_proc) {|e| true }.should == "yay"
|
48
|
-
end
|
49
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
describe :enumerable_take, :shared => true do
|
2
|
-
before :each do
|
3
|
-
@values = [4,3,2,1,0,-1]
|
4
|
-
@enum = EnumerableSpecs::Numerous.new(*@values)
|
5
|
-
end
|
6
|
-
|
7
|
-
it "returns the first count elements if given a count" do
|
8
|
-
@enum.first(2).should == [4, 3]
|
9
|
-
@enum.first(4).should == [4, 3, 2, 1]
|
10
|
-
end
|
11
|
-
|
12
|
-
it "returns an empty array when passed count on an empty array" do
|
13
|
-
empty = EnumerableSpecs::Empty.new
|
14
|
-
empty.first(0).should == []
|
15
|
-
empty.first(1).should == []
|
16
|
-
empty.first(2).should == []
|
17
|
-
end
|
18
|
-
|
19
|
-
it "returns an empty array when passed count == 0" do
|
20
|
-
@enum.first(0).should == []
|
21
|
-
end
|
22
|
-
|
23
|
-
it "returns an array containing the first element when passed count == 1" do
|
24
|
-
@enum.first(1).should == [4]
|
25
|
-
end
|
26
|
-
|
27
|
-
it "returns the entire array when count > length" do
|
28
|
-
@enum.first(100).should == @values
|
29
|
-
@enum.first(8).should == @values
|
30
|
-
end
|
31
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
#ruby_version_is "1.9" do
|
4
|
-
describe "Hash#assoc" do
|
5
|
-
before(:each) do
|
6
|
-
@h = {:apple => :green, :orange => :orange, :grape => :green, :banana => :yellow}
|
7
|
-
end
|
8
|
-
|
9
|
-
it "returns an Array is the argument is == to a key of the Hash" do
|
10
|
-
@h.assoc(:apple).should be_kind_of(Array)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "returns a 2-element Array if the argument is == to a key of the Hash" do
|
14
|
-
@h.assoc(:grape).size.should == 2
|
15
|
-
end
|
16
|
-
|
17
|
-
it "sets the first element of the Array to the located key" do
|
18
|
-
@h.assoc(:banana).first.should == :banana
|
19
|
-
end
|
20
|
-
|
21
|
-
it "sets the last element of the Array to the value of the located key" do
|
22
|
-
@h.assoc(:banana).last.should == :yellow
|
23
|
-
end
|
24
|
-
|
25
|
-
it "returns nil if the argument if not a key of the Hash" do
|
26
|
-
@h.assoc(:green).should be_nil
|
27
|
-
end
|
28
|
-
end
|
29
|
-
#end
|
File without changes
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require File.expand_path('../../../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe :regexp_match do
|
4
|
-
it "returns nil if there is no match" do
|
5
|
-
/xyz/.match("abxyc").should be_nil
|
6
|
-
end
|
7
|
-
|
8
|
-
it "returns nil if the object is nil" do
|
9
|
-
/xyz/.match(nil).should be_nil
|
10
|
-
end
|
11
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module BreakSpecs
|
2
|
-
class Driver
|
3
|
-
def initialize(ensures=false)
|
4
|
-
@ensures = ensures
|
5
|
-
end
|
6
|
-
|
7
|
-
def note(value)
|
8
|
-
ScratchPad << value
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class Block < Driver
|
13
|
-
def break_nil
|
14
|
-
note :a
|
15
|
-
note yielding {
|
16
|
-
note :b
|
17
|
-
break
|
18
|
-
note :c
|
19
|
-
}
|
20
|
-
note :d
|
21
|
-
end
|
22
|
-
|
23
|
-
def break_value
|
24
|
-
note :a
|
25
|
-
note yielding {
|
26
|
-
note :b
|
27
|
-
break :break
|
28
|
-
note :c
|
29
|
-
}
|
30
|
-
note :d
|
31
|
-
end
|
32
|
-
|
33
|
-
def yielding
|
34
|
-
note :aa
|
35
|
-
note yield
|
36
|
-
note :bb
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module EnsureSpec
|
2
|
-
class Container
|
3
|
-
attr_reader :executed
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@executed = []
|
7
|
-
end
|
8
|
-
|
9
|
-
def raise_in_method_with_ensure
|
10
|
-
@executed << :method
|
11
|
-
raise "An Exception"
|
12
|
-
ensure
|
13
|
-
@executed << :ensure
|
14
|
-
end
|
15
|
-
|
16
|
-
def raise_and_rescue_in_method_with_ensure
|
17
|
-
@executed << :method
|
18
|
-
raise "An Exception"
|
19
|
-
rescue
|
20
|
-
@executed << :rescue
|
21
|
-
ensure
|
22
|
-
@executed << :ensure
|
23
|
-
end
|
24
|
-
|
25
|
-
def implicit_return_in_method_with_ensure
|
26
|
-
:method
|
27
|
-
ensure
|
28
|
-
:ensure
|
29
|
-
end
|
30
|
-
|
31
|
-
def explicit_return_in_method_with_ensure
|
32
|
-
return :method
|
33
|
-
ensure
|
34
|
-
return :ensure
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
class NextSpecs
|
2
|
-
def self.yielding_method(expected)
|
3
|
-
yield.should == expected
|
4
|
-
:method_return_value
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.yielding
|
8
|
-
yield
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.while_next(arg)
|
12
|
-
x = true
|
13
|
-
while x
|
14
|
-
begin
|
15
|
-
ScratchPad << :begin
|
16
|
-
x = false
|
17
|
-
if arg
|
18
|
-
next 42
|
19
|
-
else
|
20
|
-
next
|
21
|
-
end
|
22
|
-
ensure
|
23
|
-
ScratchPad << :ensure
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.while_within_iter(arg)
|
29
|
-
yielding do
|
30
|
-
x = true
|
31
|
-
while x
|
32
|
-
begin
|
33
|
-
ScratchPad << :begin
|
34
|
-
x = false
|
35
|
-
if arg
|
36
|
-
next 42
|
37
|
-
else
|
38
|
-
next
|
39
|
-
end
|
40
|
-
ensure
|
41
|
-
ScratchPad << :ensure
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module LangSendSpecs
|
2
|
-
|
3
|
-
def self.fooM0; 100; end
|
4
|
-
def self.fooM1(a); [a]; end
|
5
|
-
def self.fooM2(a,b); [a,b]; end
|
6
|
-
def self.fooM3(a,b,c); [a,b,c]; end
|
7
|
-
def self.fooM4(a,b,c,d); [a,b,c,d]; end
|
8
|
-
def self.fooM5(a,b,c,d,e); [a,b,c,d,e]; end
|
9
|
-
def self.fooM0O1(a=1); [a]; end
|
10
|
-
def self.fooM1O1(a,b=1); [a,b]; end
|
11
|
-
def self.fooM2O1(a,b,c=1); [a,b,c]; end
|
12
|
-
def self.fooM3O1(a,b,c,d=1); [a,b,c,d]; end
|
13
|
-
def self.fooM4O1(a,b,c,d,e=1); [a,b,c,d,e]; end
|
14
|
-
def self.fooM0O2(a=1,b=2); [a,b]; end
|
15
|
-
def self.fooM0R(*r); r; end
|
16
|
-
def self.fooM1R(a, *r); [a, r]; end
|
17
|
-
def self.fooM0O1R(a=1, *r); [a, r]; end
|
18
|
-
def self.fooM1O1R(a, b=1, *r); [a, b, r]; end
|
19
|
-
|
20
|
-
def self.one(a); a; end
|
21
|
-
def self.oneb(a,&b); [a,yield(b)]; end
|
22
|
-
|
23
|
-
def self.makeproc(&b) b end
|
24
|
-
|
25
|
-
def self.yield_now; yield; end
|
26
|
-
|
27
|
-
class ToProc
|
28
|
-
def initialize(val)
|
29
|
-
@val = val
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_proc
|
33
|
-
Proc.new { @val }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Super
|
2
|
-
module S1
|
3
|
-
class A
|
4
|
-
def foo(a)
|
5
|
-
a << "A#foo"
|
6
|
-
bar(a)
|
7
|
-
end
|
8
|
-
def bar(a)
|
9
|
-
a << "A#bar"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
class B < A
|
13
|
-
def foo(a)
|
14
|
-
a << "B#foo"
|
15
|
-
super(a)
|
16
|
-
end
|
17
|
-
def bar(a)
|
18
|
-
a << "B#bar"
|
19
|
-
super(a)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
module S2
|
25
|
-
class A
|
26
|
-
def baz(a)
|
27
|
-
a << "A#baz"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
class B < A
|
31
|
-
def foo(a)
|
32
|
-
a << "B#foo"
|
33
|
-
baz(a)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
class C < B
|
37
|
-
def baz(a)
|
38
|
-
a << "C#baz"
|
39
|
-
super(a)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
-
require File.expand_path('../fixtures/super', __FILE__)
|
3
|
-
|
4
|
-
describe "The super keyword" do
|
5
|
-
it "calls the method on the calling class" do
|
6
|
-
Super::S1::A.new.foo([]).should == ["A#foo", "A#bar"]
|
7
|
-
Super::S1::A.new.bar([]).should == ["A#bar"]
|
8
|
-
Super::S1::B.new.foo([]).should == ["B#foo", "A#foo", "B#bar", "A#bar"]
|
9
|
-
Super::S1::B.new.bar([]).should == ["B#bar", "A#bar"]
|
10
|
-
end
|
11
|
-
|
12
|
-
it "searches the full inheritence chain" do
|
13
|
-
Super::S2::B.new.foo([]).should == ["B#foo", "A#baz"]
|
14
|
-
Super::S2::B.new.baz([]).should == ["A#baz"]
|
15
|
-
Super::S2::C.new.foo([]).should == ["B#foo", "C#baz", "A#baz"]
|
16
|
-
Super::S2::C.new.baz([]).should == ["C#baz", "A#baz"]
|
17
|
-
end
|
18
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe "Hash literal" do
|
4
|
-
describe "new-style hash syntax" do
|
5
|
-
it "constructs a new hash with the given elements" do
|
6
|
-
{foo: 123}.should == {:foo => 123}
|
7
|
-
{rbx: :cool, specs: 'fail_sometimes'}.should == {:rbx => :cool, :specs => 'fail_sometimes'}
|
8
|
-
end
|
9
|
-
|
10
|
-
it "ignores a hanging comma" do
|
11
|
-
{foo: 123,}.should == {:foo => 123}
|
12
|
-
{rbx: :cool, specs: 'fail_sometimes',}.should == {:rbx => :cool, :specs => 'fail_sometimes'}
|
13
|
-
end
|
14
|
-
|
15
|
-
it "can mix and match syntax styles" do
|
16
|
-
{rbx: :cool, :specs => 'fail_sometimes'}.should == {:rbx => :cool, :specs => 'fail_sometimes'}
|
17
|
-
{'rbx' => :cool, specs: 'fail_sometimes'}.should == {'rbx' => :cool, :specs => 'fail_sometimes'}
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|