opal 0.3.41 → 0.3.42
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +14 -1
- data/Gemfile +2 -5
- data/Rakefile +41 -3
- data/bin/opal +33 -0
- data/lib/opal.rb +2 -12
- data/lib/opal/core_ext.rb +5 -0
- data/lib/opal/grammar.rb +2207 -2138
- data/lib/opal/grammar.y +21 -0
- data/lib/opal/grammar_helpers.rb +360 -0
- data/lib/opal/lexer.rb +55 -401
- data/lib/opal/lexer_scope.rb +28 -0
- data/lib/opal/parser.rb +155 -171
- data/lib/opal/target_scope.rb +257 -0
- data/lib/opal/version.rb +1 -1
- data/opal.gemspec +6 -2
- data/opal/opal-parser.js.erb +3 -2
- data/opal/opal.rb +20 -18
- data/opal/opal/array.rb +21 -12
- data/opal/opal/basic_object.rb +2 -1
- data/opal/opal/boolean.rb +3 -0
- data/opal/opal/browser_loader.js +57 -0
- data/opal/opal/class.rb +51 -13
- data/opal/opal/date.rb +1 -20
- data/opal/opal/enumerable.rb +66 -33
- data/opal/opal/error.rb +2 -0
- data/opal/opal/hash.rb +1 -1
- data/opal/opal/kernel.rb +14 -3
- data/opal/opal/nil_class.rb +4 -0
- data/opal/opal/proc.rb +9 -1
- data/opal/opal/racc.rb +2 -2
- data/opal/opal/regexp.rb +1 -1
- data/opal/opal/runtime.js +14 -4
- data/opal/opal/string.rb +21 -4
- data/opal/opal/time.rb +27 -0
- data/spec/core/array/allocate_spec.rb +7 -1
- data/spec/core/array/append_spec.rb +18 -3
- data/spec/core/array/array_spec.rb +7 -0
- data/spec/core/array/assoc_spec.rb +23 -8
- data/spec/core/array/at_spec.rb +23 -3
- data/spec/core/array/choice_spec.rb +20 -0
- data/spec/core/array/clear_spec.rb +45 -4
- data/spec/core/array/combination_spec.rb +55 -0
- data/spec/core/array/compact_spec.rb +72 -1
- data/spec/core/array/constructor_spec.rb +13 -2
- data/spec/core/array/count_spec.rb +15 -7
- data/spec/core/array/delete_at_spec.rb +44 -1
- data/spec/core/array/delete_if_spec.rb +52 -2
- data/spec/core/array/delete_spec.rb +83 -2
- data/spec/core/array/drop_spec.rb +24 -16
- data/spec/core/array/drop_while_spec.rb +17 -0
- data/spec/core/array/each_index_spec.rb +11 -1
- data/spec/core/array/each_spec.rb +20 -2
- data/spec/core/array/empty_spec.rb +4 -1
- data/spec/core/array/eql_spec.rb +14 -0
- data/spec/core/array/fetch_spec.rb +31 -2
- data/spec/core/array/find_index_spec.rb +8 -0
- data/spec/core/array/first_spec.rb +45 -8
- data/spec/core/array/fixtures/classes.rb +538 -0
- data/spec/core/array/flatten_spec.rb +200 -7
- data/spec/core/array/frozen_spec.rb +32 -0
- data/spec/core/array/include_spec.rb +16 -1
- data/spec/core/array/index_spec.rb +5 -25
- data/spec/core/array/insert_spec.rb +37 -3
- data/spec/core/array/inspect_spec.rb +6 -12
- data/spec/core/array/intersection_spec.rb +55 -4
- data/spec/core/array/join_spec.rb +29 -4
- data/spec/core/array/keep_if_spec.rb +13 -6
- data/spec/core/array/last_spec.rb +35 -1
- data/spec/core/array/length_spec.rb +7 -4
- data/spec/core/array/map_spec.rb +9 -47
- data/spec/core/array/minus_spec.rb +68 -4
- data/spec/core/array/multiply_spec.rb +138 -6
- data/spec/core/array/new_spec.rb +92 -3
- data/spec/core/array/ntimes_spec.rb +26 -0
- data/spec/core/array/plus_spec.rb +48 -2
- data/spec/core/array/pop_spec.rb +159 -39
- data/spec/core/array/push_spec.rb +29 -1
- data/spec/core/array/rassoc_spec.rb +31 -2
- data/spec/core/array/reject_spec.rb +89 -2
- data/spec/core/array/replace_spec.rb +7 -29
- data/spec/core/array/reverse_each_spec.rb +25 -1
- data/spec/core/array/reverse_spec.rb +53 -1
- data/spec/core/array/rindex_spec.rb +55 -5
- data/spec/core/array/select_spec.rb +35 -8
- data/spec/core/array/shared/collect.rb +0 -0
- data/spec/core/array/shared/enumeratorize.rb +12 -0
- data/spec/core/array/shared/eql.rb +95 -0
- data/spec/core/array/shared/index.rb +37 -0
- data/spec/core/array/shared/inspect.rb +3 -0
- data/spec/core/array/shared/join.rb +7 -0
- data/spec/core/array/shared/keep_if.rb +0 -0
- data/spec/core/array/shared/length.rb +0 -0
- data/spec/core/array/shared/replace.rb +0 -0
- data/spec/core/array/shared/slice.rb +0 -0
- data/spec/core/array/shift_spec.rb +132 -23
- data/spec/core/array/shuffle_spec.rb +82 -6
- data/spec/core/array/size_spec.rb +7 -4
- data/spec/core/array/slice_spec.rb +132 -1
- data/spec/core/array/sort_spec.rb +263 -14
- data/spec/core/array/take_spec.rb +24 -16
- data/spec/core/array/take_while_spec.rb +14 -10
- data/spec/core/array/to_a_spec.rb +18 -1
- data/spec/core/array/to_ary_spec.rb +15 -1
- data/spec/core/array/try_convert_spec.rb +39 -2
- data/spec/core/array/uniq_spec.rb +148 -3
- data/spec/core/array/unshift_spec.rb +36 -1
- data/spec/core/array/zip_spec.rb +36 -1
- data/spec/core/class/new_spec.rb +8 -6
- data/spec/core/enumerable/all_spec.rb +37 -9
- data/spec/core/enumerable/any_spec.rb +45 -7
- data/spec/core/enumerable/collect_spec.rb +4 -1
- data/spec/core/enumerable/count_spec.rb +4 -1
- data/spec/core/enumerable/detect_spec.rb +2 -2
- data/spec/core/enumerable/drop_spec.rb +4 -1
- data/spec/core/enumerable/drop_while_spec.rb +4 -1
- data/spec/core/enumerable/each_slice_spec.rb +2 -1
- data/spec/core/enumerable/each_with_index_spec.rb +4 -1
- data/spec/core/enumerable/each_with_object_spec.rb +4 -1
- data/spec/core/enumerable/entries_spec.rb +4 -1
- data/spec/core/enumerable/find_all_spec.rb +4 -1
- data/spec/core/enumerable/find_index_spec.rb +4 -1
- data/spec/core/enumerable/find_spec.rb +5 -2
- data/spec/core/enumerable/first_spec.rb +4 -1
- data/spec/core/enumerable/fixtures/classes.rb +198 -2
- data/spec/core/enumerable/grep_spec.rb +4 -1
- data/spec/core/enumerable/take_spec.rb +4 -1
- data/spec/core/enumerable/to_a_spec.rb +4 -1
- data/spec/core/false/and_spec.rb +11 -0
- data/spec/core/false/inspect_spec.rb +7 -0
- data/spec/core/false/or_spec.rb +11 -0
- data/spec/core/false/to_s_spec.rb +7 -0
- data/spec/core/false/xor_spec.rb +11 -0
- data/spec/core/kernel/rand_spec.rb +5 -5
- data/spec/core/module/const_get_spec.rb +4 -4
- data/spec/core/module/fixtures/classes.rb +434 -0
- data/spec/core/module/method_defined_spec.rb +49 -0
- data/spec/core/module/module_function_spec.rb +28 -0
- data/spec/core/nil/and_spec.rb +3 -1
- data/spec/core/nil/dup_spec.rb +7 -0
- data/spec/core/nil/inspect_spec.rb +3 -1
- data/spec/core/nil/nil_spec.rb +3 -1
- data/spec/core/nil/or_spec.rb +4 -2
- data/spec/core/nil/to_a_spec.rb +3 -1
- data/spec/core/nil/to_f_spec.rb +3 -1
- data/spec/core/nil/to_i_spec.rb +3 -1
- data/spec/core/nil/to_s_spec.rb +3 -1
- data/spec/core/nil/xor_spec.rb +4 -2
- data/spec/core/string/element_reference_spec.rb +14 -1
- data/spec/core/string/fixtures/classes.rb +0 -0
- data/spec/core/true/and_spec.rb +11 -0
- data/spec/core/true/inspect_spec.rb +7 -0
- data/spec/core/true/or_spec.rb +11 -0
- data/spec/core/true/to_s_spec.rb +7 -0
- data/spec/core/true/xor_spec.rb +11 -0
- data/spec/{core → core_ext}/array/element_reference_spec.rb +0 -0
- data/spec/{core → core_ext}/array/equal_value_spec.rb +0 -0
- data/spec/{core → core_ext}/array/fill_spec.rb +0 -0
- data/spec/{core → core_ext}/array/reduce_spec.rb +0 -0
- data/spec/core_ext/basic_object/send_spec.rb +3 -3
- data/spec/{core → core_ext}/boolean/singleton_class_spec.rb +0 -0
- data/spec/{core → core_ext}/boolean/to_json_spec.rb +0 -0
- data/spec/core_ext/class/_inherited_spec.rb +3 -3
- data/spec/core_ext/class/proc_methods_spec.rb +2 -2
- data/spec/core_ext/class/singleton_methods_spec.rb +8 -8
- data/spec/core_ext/method_missing_spec.rb +3 -3
- data/spec/core_ext/native/method_missing_spec.rb +3 -2
- data/spec/core_ext/native/to_native_spec.rb +3 -2
- data/spec/{core → core_ext}/nil/to_json_spec.rb +0 -0
- data/spec/date.rb +0 -0
- data/spec/fileutils.rb +0 -0
- data/spec/filters/ancestors.rb +4 -0
- data/spec/filters/array_delete.rb +3 -0
- data/spec/filters/array_fetch.rb +3 -0
- data/spec/filters/array_first.rb +3 -0
- data/spec/filters/array_flatten.rb +14 -0
- data/spec/filters/array_intersection.rb +5 -0
- data/spec/filters/array_join.rb +6 -0
- data/spec/filters/array_subclasses.rb +4 -0
- data/spec/filters/block_args.rb +3 -0
- data/spec/filters/coerce_integer.rb +9 -0
- data/spec/filters/frozen.rb +4 -0
- data/spec/filters/mocks.rb +3 -0
- data/spec/filters/should_receive.rb +4 -0
- data/spec/filters/tainted.rb +7 -0
- data/spec/fixtures/class.rb +124 -0
- data/spec/fixtures/class_variables.rb +0 -0
- data/spec/fixtures/constants.rb +0 -0
- data/spec/grammar/alias_spec.rb +1 -1
- data/spec/grammar/def_spec.rb +1 -0
- data/spec/grammar/lvar_spec.rb +1 -2
- data/spec/grammar/nth_ref_spec.rb +13 -0
- data/spec/grammar/sclass_spec.rb +6 -7
- data/spec/grammar/str_spec.rb +4 -4
- data/spec/grammar/string_spec.rb +8 -0
- data/spec/grammar/xstr_spec.rb +4 -4
- data/spec/iconv.rb +0 -0
- data/spec/language/alias_spec.rb +140 -3
- data/spec/language/and_spec.rb +14 -7
- data/spec/language/array_spec.rb +57 -5
- data/spec/language/block_spec.rb +466 -49
- data/spec/language/break_spec.rb +294 -44
- data/spec/language/case_spec.rb +151 -3
- data/spec/language/class_spec.rb +196 -0
- data/spec/language/class_variable_spec.rb +56 -0
- data/spec/language/def_spec.rb +507 -4
- data/spec/language/defined_spec.rb +19 -7
- data/spec/language/ensure_spec.rb +26 -39
- data/spec/language/execution_spec.rb +15 -0
- data/spec/language/fixtures/array.rb +11 -0
- data/spec/language/fixtures/block.rb +57 -0
- data/spec/language/fixtures/break.rb +240 -0
- data/spec/language/fixtures/ensure.rb +72 -0
- data/spec/language/fixtures/literal_lambda.rb +7 -0
- data/spec/language/fixtures/metaclass.rb +33 -0
- data/spec/language/fixtures/module.rb +24 -0
- data/spec/language/fixtures/next.rb +78 -12
- data/spec/language/fixtures/return.rb +118 -0
- data/spec/language/fixtures/send.rb +110 -0
- data/spec/language/fixtures/send_1.9.rb +22 -0
- data/spec/language/fixtures/super.rb +308 -0
- data/spec/language/fixtures/variables.rb +58 -0
- data/spec/language/fixtures/yield.rb +5 -0
- data/spec/language/for_spec.rb +192 -0
- data/spec/language/hash_spec.rb +29 -5
- data/spec/language/if_spec.rb +90 -9
- data/spec/language/literal_lambda_spec.rb +1 -47
- data/spec/language/loop_spec.rb +39 -2
- data/spec/language/metaclass_spec.rb +151 -5
- data/spec/language/module_spec.rb +56 -0
- data/spec/language/next_spec.rb +370 -12
- data/spec/language/not_spec.rb +55 -0
- data/spec/language/numbers_spec.rb +56 -0
- data/spec/language/or_spec.rb +31 -3
- data/spec/language/order_spec.rb +79 -0
- data/spec/language/precedence_spec.rb +483 -0
- data/spec/language/proc_spec.rb +249 -21
- data/spec/language/redo_spec.rb +67 -0
- data/spec/language/rescue_spec.rb +121 -0
- data/spec/language/retry_spec.rb +56 -0
- data/spec/language/return_spec.rb +281 -0
- data/spec/language/send_spec.rb +141 -48
- data/spec/language/singleton_class_spec.rb +1 -1
- data/spec/language/string_spec.rb +11 -0
- data/spec/language/super_spec.rb +213 -133
- data/spec/language/symbol_spec.rb +2 -1
- data/spec/language/undef_spec.rb +3 -1
- data/spec/language/unless_spec.rb +6 -2
- data/spec/language/until_spec.rb +102 -3
- data/spec/language/variables_spec.rb +1212 -16
- data/spec/language/versions/array_1.9.rb +39 -0
- data/spec/language/versions/case_1.9.rb +20 -0
- data/spec/language/versions/hash_1.9.rb +18 -0
- data/spec/language/versions/literal_lambda_1.9.rb +143 -0
- data/spec/language/versions/not_1.9.rb +22 -0
- data/spec/language/versions/send_1.9.rb +241 -0
- data/spec/language/versions/symbol_1.9.rb +15 -0
- data/spec/language/versions/variables_1.9.rb +8 -0
- data/spec/language/while_spec.rb +70 -5
- data/spec/language/yield_spec.rb +32 -6
- data/spec/mspec/guards/block_device.rb +0 -0
- data/spec/mspec/guards/endian.rb +0 -0
- data/spec/mspec/helpers/environment.rb +0 -0
- data/spec/mspec/helpers/language_version.rb +0 -0
- data/spec/mspec/helpers/tmp.rb +0 -0
- data/spec/ospec/filter.rb +32 -0
- data/spec/ospec/main.rb.erb +18 -0
- data/spec/ospec/phantom.rb +97 -0
- data/spec/ospec/runner.rb +95 -0
- data/spec/ospec/sprockets.js +40 -0
- data/spec/pp.rb +3 -0
- data/spec/rbconfig.rb +5 -0
- data/spec/spec_helper.rb +53 -26
- data/spec/yaml.rb +0 -0
- metadata +275 -31
- data/config.ru +0 -8
- data/lib/opal/processor.rb +0 -47
- data/lib/opal/scope.rb +0 -236
- data/lib/opal/server.rb +0 -94
- data/spec/core/boolean/and_spec.rb +0 -17
- data/spec/core/boolean/inspect_spec.rb +0 -9
- data/spec/core/boolean/or_spec.rb +0 -17
- data/spec/core/boolean/to_s_spec.rb +0 -9
- data/spec/core/boolean/xor_spec.rb +0 -17
@@ -2,4 +2,15 @@ describe "Ruby character strings" do
|
|
2
2
|
it "are produced from character shortcuts" do
|
3
3
|
?z.should == 'z'
|
4
4
|
end
|
5
|
+
|
6
|
+
it "should parse string into %[]" do
|
7
|
+
%[foo].should == "foo"
|
8
|
+
%|bar|.should == "bar"
|
9
|
+
%'baz'.should == "baz"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "interpolate string" do
|
13
|
+
a = 1
|
14
|
+
%[#{a}23].should == "123"
|
15
|
+
end
|
5
16
|
end
|
data/spec/language/super_spec.rb
CHANGED
@@ -1,208 +1,288 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
require File.expand_path('../fixtures/super', __FILE__)
|
3
|
+
|
1
4
|
describe "The super keyword" do
|
2
5
|
it "calls the method on the calling class" do
|
3
|
-
Super::S1::A.new.foo([]).should == ["A#foo",
|
6
|
+
Super::S1::A.new.foo([]).should == ["A#foo","A#bar"]
|
4
7
|
Super::S1::A.new.bar([]).should == ["A#bar"]
|
5
|
-
Super::S1::B.new.foo([]).should == ["B#foo",
|
6
|
-
Super::S1::B.new.bar([]).should == ["B#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"]
|
7
10
|
end
|
8
11
|
|
9
12
|
it "searches the full inheritence chain" do
|
10
|
-
Super::S2::B.new.foo([]).should == ["B#foo",
|
13
|
+
Super::S2::B.new.foo([]).should == ["B#foo","A#baz"]
|
11
14
|
Super::S2::B.new.baz([]).should == ["A#baz"]
|
12
|
-
Super::S2::C.new.foo([]).should == ["B#foo",
|
13
|
-
Super::S2::C.new.baz([]).should == ["C#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"]
|
14
17
|
end
|
15
18
|
|
16
19
|
it "searches class methods" do
|
17
20
|
Super::S3::A.new.foo([]).should == ["A#foo"]
|
18
21
|
Super::S3::A.foo([]).should == ["A::foo"]
|
19
|
-
Super::S3::A.bar([]).should == ["A::bar",
|
22
|
+
Super::S3::A.bar([]).should == ["A::bar","A::foo"]
|
20
23
|
Super::S3::B.new.foo([]).should == ["A#foo"]
|
21
|
-
Super::S3::B.foo([]).should == ["B::foo",
|
22
|
-
Super::S3::B.bar([]).should == ["B::bar",
|
24
|
+
Super::S3::B.foo([]).should == ["B::foo","A::foo"]
|
25
|
+
Super::S3::B.bar([]).should == ["B::bar","A::bar","B::foo","A::foo"]
|
23
26
|
end
|
24
27
|
|
25
28
|
it "calls the method on the calling class including modules" do
|
26
|
-
Super::MS1::A.new.foo([]).should == ["ModA#foo",
|
29
|
+
Super::MS1::A.new.foo([]).should == ["ModA#foo","ModA#bar"]
|
27
30
|
Super::MS1::A.new.bar([]).should == ["ModA#bar"]
|
28
31
|
Super::MS1::B.new.foo([]).should == ["B#foo","ModA#foo","ModB#bar","ModA#bar"]
|
29
|
-
Super::MS1::B.new.bar([]).should == ["ModB#bar",
|
32
|
+
Super::MS1::B.new.bar([]).should == ["ModB#bar","ModA#bar"]
|
30
33
|
end
|
31
34
|
|
32
35
|
it "searches the full inheritence chain including modules" do
|
33
|
-
Super::MS2::B.new.foo([]).should == ["ModB#foo",
|
36
|
+
Super::MS2::B.new.foo([]).should == ["ModB#foo","A#baz"]
|
34
37
|
Super::MS2::B.new.baz([]).should == ["A#baz"]
|
35
|
-
Super::MS2::C.new.baz([]).should == ["C#baz",
|
38
|
+
Super::MS2::C.new.baz([]).should == ["C#baz","A#baz"]
|
36
39
|
Super::MS2::C.new.foo([]).should == ["ModB#foo","C#baz","A#baz"]
|
37
40
|
end
|
38
41
|
|
42
|
+
pending "searches class methods including modules" do
|
43
|
+
Super::MS3::A.new.foo([]).should == ["A#foo"]
|
44
|
+
Super::MS3::A.foo([]).should == ["ModA#foo"]
|
45
|
+
Super::MS3::A.bar([]).should == ["ModA#bar","ModA#foo"]
|
46
|
+
Super::MS3::B.new.foo([]).should == ["A#foo"]
|
47
|
+
Super::MS3::B.foo([]).should == ["B::foo","ModA#foo"]
|
48
|
+
Super::MS3::B.bar([]).should == ["B::bar","ModA#bar","B::foo","ModA#foo"]
|
49
|
+
end
|
50
|
+
|
51
|
+
pending "calls the correct method when the method visibility is modified" do
|
52
|
+
Super::MS4::A.new.example.should == 5
|
53
|
+
end
|
54
|
+
|
55
|
+
it "calls the correct method when the superclass argument list is different from the subclass" do
|
56
|
+
Super::S4::A.new.foo([]).should == ["A#foo"]
|
57
|
+
Super::S4::B.new.foo([],"test").should == ["B#foo(a,test)", "A#foo"]
|
58
|
+
end
|
59
|
+
|
60
|
+
pending do
|
61
|
+
ruby_bug "#1151 [ruby-core:22040]", "1.8.7.174" do
|
62
|
+
it "raises an error error when super method does not exist" do
|
63
|
+
sup = Class.new
|
64
|
+
sub_normal = Class.new(sup) do
|
65
|
+
def foo
|
66
|
+
super()
|
67
|
+
end
|
68
|
+
end
|
69
|
+
sub_zsuper = Class.new(sup) do
|
70
|
+
def foo
|
71
|
+
super
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
lambda {sub_normal.new.foo}.should raise_error(NoMethodError, /super/)
|
76
|
+
lambda {sub_zsuper.new.foo}.should raise_error(NoMethodError, /super/)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
39
81
|
it "calls the superclass method when in a block" do
|
40
82
|
Super::S6.new.here.should == :good
|
41
83
|
end
|
42
84
|
|
43
|
-
it "calls the superclass when initial method is
|
85
|
+
it "calls the superclass method when initial method is defined_method'd" do
|
44
86
|
Super::S7.new.here.should == :good
|
45
87
|
end
|
46
88
|
|
47
|
-
|
48
|
-
|
49
|
-
|
89
|
+
it "can call through a define_method multiple times (caching check)" do
|
90
|
+
obj = Super::S7.new
|
91
|
+
|
92
|
+
2.times do
|
93
|
+
obj.here.should == :good
|
50
94
|
end
|
51
95
|
end
|
52
|
-
end
|
53
96
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
def
|
58
|
-
[a, b, c]
|
59
|
-
end
|
97
|
+
it "supers up appropriate name even if used for multiple method names" do
|
98
|
+
sup = Class.new do
|
99
|
+
def a; "a"; end
|
100
|
+
def b; "b"; end
|
60
101
|
end
|
61
102
|
|
62
|
-
|
63
|
-
|
64
|
-
|
103
|
+
sub = Class.new(sup) do
|
104
|
+
[:a, :b].each do |name|
|
105
|
+
define_method name do
|
106
|
+
super()
|
107
|
+
end
|
65
108
|
end
|
66
109
|
end
|
110
|
+
|
111
|
+
sub.new.a.should == "a"
|
112
|
+
sub.new.b.should == "b"
|
113
|
+
sub.new.a.should == "a"
|
67
114
|
end
|
68
115
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
a
|
73
|
-
bar(a)
|
116
|
+
ruby_version_is ""..."1.9" do
|
117
|
+
it "can be used with zero implicit arguments from a method defined with define_method" do
|
118
|
+
sup = Class.new do
|
119
|
+
def a; "a"; end
|
74
120
|
end
|
75
|
-
|
76
|
-
|
121
|
+
|
122
|
+
sub = Class.new(sup) do
|
123
|
+
define_method :a do
|
124
|
+
super
|
125
|
+
end
|
77
126
|
end
|
127
|
+
|
128
|
+
sub.new.a.should == "a"
|
78
129
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
84
|
-
def bar(a)
|
85
|
-
a << "B#bar"
|
86
|
-
super(a)
|
130
|
+
|
131
|
+
it "can be used with non-zero implicit arguments from a method defined with define_method" do
|
132
|
+
sup = Class.new do
|
133
|
+
def a(n1, n2); n1 + n2; end
|
87
134
|
end
|
88
|
-
end
|
89
|
-
end
|
90
135
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
136
|
+
sub = Class.new(sup) do
|
137
|
+
define_method :a do |*args|
|
138
|
+
super
|
139
|
+
end
|
95
140
|
end
|
141
|
+
|
142
|
+
sub.new.a(30,12).should == 42
|
96
143
|
end
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
144
|
+
|
145
|
+
it "passes along optional args in all cases" do
|
146
|
+
sup = Class.new do
|
147
|
+
def a(n1, n2); n1 + n2; end
|
101
148
|
end
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
149
|
+
|
150
|
+
sub = Class.new(sup) do
|
151
|
+
def a(n1, n2=2)
|
152
|
+
super
|
153
|
+
end
|
107
154
|
end
|
155
|
+
|
156
|
+
sub.new.a(39, 3).should == 42
|
157
|
+
sub.new.a(40).should == 42
|
108
158
|
end
|
109
|
-
end
|
110
159
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
160
|
+
describe "passes along unnamed rest args" do
|
161
|
+
before(:each) do
|
162
|
+
@sup = Class.new do
|
163
|
+
def a(n1, *n2); return n1 + n2[0]; end
|
164
|
+
end
|
115
165
|
end
|
116
|
-
|
117
|
-
|
166
|
+
|
167
|
+
it "" do
|
168
|
+
sub = Class.new(@sup) do
|
169
|
+
def a(n, *)
|
170
|
+
super
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
sub.new.a(30, 12).should == 42
|
118
175
|
end
|
119
|
-
|
120
|
-
|
121
|
-
|
176
|
+
|
177
|
+
it "even when nested within a block" do
|
178
|
+
sub = Class.new(@sup) do
|
179
|
+
def yieldit; yield; end
|
180
|
+
|
181
|
+
def a(n, *)
|
182
|
+
yieldit { super }
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
sub.new.a(30, 12).should == 42
|
122
187
|
end
|
123
188
|
end
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
189
|
+
|
190
|
+
describe "passes along the incoming block to the super method" do
|
191
|
+
before(:each) do
|
192
|
+
@sup = Class.new do
|
193
|
+
def a(*n); yield n; end
|
194
|
+
end
|
128
195
|
end
|
129
|
-
|
130
|
-
|
131
|
-
|
196
|
+
|
197
|
+
it "" do
|
198
|
+
sub = Class.new(@sup) do
|
199
|
+
def a(*n); super; end
|
200
|
+
end
|
201
|
+
|
202
|
+
sub.new.a { 42 }.should == 42
|
203
|
+
end
|
204
|
+
|
205
|
+
it "even when the method has args" do
|
206
|
+
sub = Class.new(@sup) do
|
207
|
+
def a(*n); super; end
|
208
|
+
end
|
209
|
+
|
210
|
+
sub.new.a(42) {|i| i}.should == [42]
|
211
|
+
end
|
212
|
+
|
213
|
+
it "even when incoming args are explicitly passed in" do
|
214
|
+
sub = Class.new(@sup) do
|
215
|
+
def a(*n); super(*n); end
|
216
|
+
end
|
217
|
+
|
218
|
+
sub.new.a(42) {|i| i}.should == [42]
|
132
219
|
end
|
133
220
|
end
|
134
221
|
end
|
135
222
|
|
136
|
-
|
137
|
-
|
138
|
-
|
223
|
+
ruby_version_is "1.9"..."2.0" do
|
224
|
+
it "can't be used with implicit arguments from a method defined with define_method" do
|
225
|
+
Class.new do
|
226
|
+
define_method :a do
|
227
|
+
super
|
228
|
+
end.should raise_error(RuntimeError)
|
229
|
+
end
|
139
230
|
end
|
140
231
|
end
|
141
232
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
233
|
+
pending do
|
234
|
+
ruby_bug "#6907", "2.0" do
|
235
|
+
it "can be used with implicit arguments from a method defined with define_method" do
|
236
|
+
super_class = Class.new do
|
237
|
+
def a(arg)
|
238
|
+
arg
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
klass = Class.new super_class do
|
243
|
+
define_method :a do |arg|
|
244
|
+
super
|
245
|
+
end
|
246
|
+
end
|
146
247
|
|
147
|
-
|
148
|
-
under {
|
149
|
-
super
|
150
|
-
}
|
248
|
+
klass.new.a(:a_called).should == :a_called
|
151
249
|
end
|
152
250
|
end
|
251
|
+
end
|
153
252
|
|
154
|
-
|
155
|
-
|
253
|
+
# Rubinius ticket github#157
|
254
|
+
pending "calls method_missing when a superclass method is not found" do
|
255
|
+
lambda {
|
256
|
+
Super::MM_B.new.is_a?(Hash).should == false
|
257
|
+
}.should_not raise_error(NoMethodError)
|
156
258
|
end
|
157
259
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
end
|
164
|
-
def bar(a)
|
165
|
-
a << "ModA#bar"
|
166
|
-
end
|
167
|
-
end
|
168
|
-
class A
|
169
|
-
include ModA
|
170
|
-
end
|
171
|
-
module ModB
|
172
|
-
def bar(a)
|
173
|
-
a << "ModB#bar"
|
174
|
-
super(a)
|
175
|
-
end
|
176
|
-
end
|
177
|
-
class B < A
|
178
|
-
def foo(a)
|
179
|
-
a << "B#foo"
|
180
|
-
super(a)
|
181
|
-
end
|
182
|
-
include ModB
|
183
|
-
end
|
260
|
+
# Rubinius ticket github#180
|
261
|
+
pending "respects the original module a method is aliased from" do
|
262
|
+
lambda {
|
263
|
+
Super::Alias3.new.name3.should == [:alias2, :alias1]
|
264
|
+
}.should_not raise_error(RuntimeError)
|
184
265
|
end
|
185
266
|
|
186
|
-
module
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
include ModB
|
267
|
+
pending "sees the included version of a module a method is alias from" do
|
268
|
+
lambda {
|
269
|
+
Super::AliasWithSuper::Trigger.foo.should == [:b, :a]
|
270
|
+
}.should_not raise_error(NoMethodError)
|
271
|
+
end
|
272
|
+
|
273
|
+
pending "passes along modified rest args when they weren't originally empty" do
|
274
|
+
Super::RestArgsWithSuper::B.new.a("bar").should == ["bar", "foo"]
|
275
|
+
end
|
276
|
+
|
277
|
+
ruby_version_is ""..."1.9" do
|
278
|
+
it "passes empty args instead of modified rest args when they were originally empty" do
|
279
|
+
Super::RestArgsWithSuper::B.new.a.should == []
|
200
280
|
end
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
281
|
+
end
|
282
|
+
|
283
|
+
ruby_version_is "1.9" do
|
284
|
+
pending "passes along modified rest args when they were originally empty" do
|
285
|
+
Super::RestArgsWithSuper::B.new.a.should == ["foo"]
|
206
286
|
end
|
207
287
|
end
|
208
|
-
end
|
288
|
+
end
|
@@ -30,10 +30,11 @@ describe "A Symbol literal" do
|
|
30
30
|
[:"foo #{1 + 1}", ':"foo 2"']
|
31
31
|
].each {
|
32
32
|
# FIXME: Symbols are Strings, so #inspect wont work
|
33
|
+
1.should == 1
|
33
34
|
}
|
34
35
|
end
|
35
36
|
|
36
37
|
it "may contain '::' in the string" do
|
37
38
|
:'Some::Class'.should be_kind_of(Symbol)
|
38
39
|
end
|
39
|
-
end
|
40
|
+
end
|