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
@@ -1,3 +1,6 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
require File.expand_path('../fixtures/classes', __FILE__)
|
3
|
+
|
1
4
|
class EnumerableSpecGrep
|
2
5
|
def ===(obj); obj == '2'; end
|
3
6
|
end
|
@@ -18,4 +21,4 @@ describe "Enumerable#grep" do
|
|
18
21
|
it "grep with a block should return an array of elements === pattern passed through block" do
|
19
22
|
EnumerableSpecs::Numerous.new("cat", "coat", "car", "cadr", "cost").grep(EnumerableSpecGrep2.new) { |i| i.upcase }.should == ["CAT", "CAR", "CADR"]
|
20
23
|
end
|
21
|
-
end
|
24
|
+
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
require File.expand_path('../fixtures/classes', __FILE__)
|
3
|
+
|
1
4
|
describe "Enumerable#take" do
|
2
5
|
before :each do
|
3
6
|
@values = [4,3,2,1,0,-1]
|
@@ -37,4 +40,4 @@ describe "Enumerable#take" do
|
|
37
40
|
@enum.take(100).should == @values
|
38
41
|
@enum.take(8).should == @values
|
39
42
|
end
|
40
|
-
end
|
43
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
require File.expand_path('../fixtures/classes', __FILE__)
|
3
|
+
|
1
4
|
describe "Enumerable#to_a" do
|
2
5
|
it "returns an array containing the elements" do
|
3
6
|
numerous = EnumerableSpecs::Numerous.new(1, nil, 'a', 2, false, true)
|
4
7
|
numerous.to_a.should == [1, nil, "a", 2, false, true]
|
5
8
|
end
|
6
|
-
end
|
9
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe "FalseClass#&" do
|
4
|
+
it "returns false" do
|
5
|
+
(false & false).should == false
|
6
|
+
(false & true).should == false
|
7
|
+
(false & nil).should == false
|
8
|
+
(false & "").should == false
|
9
|
+
(false & mock('x')).should == false
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe "FalseClass#|" do
|
4
|
+
it "return false if other is nil or false, otherwise true" do
|
5
|
+
(false | false).should == false
|
6
|
+
(false | true).should == true
|
7
|
+
(false | nil).should == false
|
8
|
+
(false | "").should == true
|
9
|
+
(false | mock('x')).should == true
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe "FalseClass#^" do
|
4
|
+
it "returns false if other is nil or false, otherwise true" do
|
5
|
+
(false ^ false).should == false
|
6
|
+
(false ^ true).should == true
|
7
|
+
(false ^ nil).should == false
|
8
|
+
(false ^ "").should == true
|
9
|
+
(false ^ mock('x')).should == true
|
10
|
+
end
|
11
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
describe "Kernel.rand" do
|
2
|
-
|
3
|
-
|
2
|
+
pending "returns a float if no argument is passed" do
|
3
|
+
rand.should be_kind_of(Float)
|
4
4
|
end
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
pending "returns an integer for an integer argument" do
|
7
|
+
rand(77).should be_kind_of(Integer)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "returns a numeric in opal" do
|
11
11
|
rand.should be_kind_of(Numeric)
|
12
12
|
rand(77).should be_kind_of(Numeric)
|
13
13
|
end
|
14
|
-
end
|
14
|
+
end
|
@@ -26,9 +26,9 @@ describe "Module#const_get" do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "searches parent scopes of classes and modules" do
|
29
|
-
ConstGetSpecs::Bar::Baz.const_get(:BAZ).should
|
30
|
-
ConstGetSpecs::Bar::Baz.const_get(:BAR).should
|
31
|
-
ConstGetSpecs::Bar::Baz.const_get(:FOO).should
|
32
|
-
ConstGetSpecs::Bar::Baz.const_get(:Bar).should
|
29
|
+
ConstGetSpecs::Bar::Baz.const_get(:BAZ).should == 300
|
30
|
+
ConstGetSpecs::Bar::Baz.const_get(:BAR).should == 200
|
31
|
+
ConstGetSpecs::Bar::Baz.const_get(:FOO).should == 100
|
32
|
+
ConstGetSpecs::Bar::Baz.const_get(:Bar).should == ConstGetSpecs::Bar
|
33
33
|
end
|
34
34
|
end
|
@@ -0,0 +1,434 @@
|
|
1
|
+
module ModuleSpecs
|
2
|
+
CONST = :plain_constant
|
3
|
+
|
4
|
+
class Subclass < Module
|
5
|
+
end
|
6
|
+
|
7
|
+
class SubclassSpec
|
8
|
+
end
|
9
|
+
|
10
|
+
class RemoveClassVariable
|
11
|
+
end
|
12
|
+
|
13
|
+
module LookupModInMod
|
14
|
+
INCS = :ethereal
|
15
|
+
end
|
16
|
+
|
17
|
+
module LookupMod
|
18
|
+
include LookupModInMod
|
19
|
+
|
20
|
+
MODS = :rockers
|
21
|
+
end
|
22
|
+
|
23
|
+
class Lookup
|
24
|
+
include LookupMod
|
25
|
+
LOOKIE = :lookie
|
26
|
+
end
|
27
|
+
|
28
|
+
class LookupChild < Lookup
|
29
|
+
end
|
30
|
+
|
31
|
+
class Parent
|
32
|
+
# For private_class_method spec
|
33
|
+
#def self.private_method; end
|
34
|
+
#private_class_method :private_method
|
35
|
+
|
36
|
+
def undefed_method() end
|
37
|
+
undef_method :undefed_method
|
38
|
+
|
39
|
+
def parent_method; end
|
40
|
+
def another_parent_method; end
|
41
|
+
|
42
|
+
# For public_class_method spec
|
43
|
+
private
|
44
|
+
def self.public_method; end
|
45
|
+
# public_class_method :public_method
|
46
|
+
|
47
|
+
public
|
48
|
+
def public_parent() end
|
49
|
+
|
50
|
+
protected
|
51
|
+
def protected_parent() end
|
52
|
+
|
53
|
+
private
|
54
|
+
def private_parent() end
|
55
|
+
end
|
56
|
+
|
57
|
+
module Basic
|
58
|
+
def public_module() end
|
59
|
+
|
60
|
+
protected
|
61
|
+
def protected_module() end
|
62
|
+
|
63
|
+
private
|
64
|
+
def private_module() end
|
65
|
+
end
|
66
|
+
|
67
|
+
module Super
|
68
|
+
include Basic
|
69
|
+
|
70
|
+
def public_super_module() end
|
71
|
+
|
72
|
+
protected
|
73
|
+
def protected_super_module() end
|
74
|
+
|
75
|
+
private
|
76
|
+
def private_super_module() end
|
77
|
+
|
78
|
+
def super_included_method; end
|
79
|
+
|
80
|
+
class SuperChild
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
module Internal
|
85
|
+
end
|
86
|
+
|
87
|
+
class Child < Parent
|
88
|
+
include Super
|
89
|
+
|
90
|
+
class << self
|
91
|
+
# include Internal
|
92
|
+
end
|
93
|
+
attr_accessor :accessor_method
|
94
|
+
|
95
|
+
def undefed_child() end
|
96
|
+
|
97
|
+
def public_child() end
|
98
|
+
|
99
|
+
undef_method :parent_method
|
100
|
+
undef_method :another_parent_method
|
101
|
+
|
102
|
+
protected
|
103
|
+
def protected_child() end
|
104
|
+
|
105
|
+
private
|
106
|
+
def private_child() end
|
107
|
+
end
|
108
|
+
|
109
|
+
class Grandchild < Child
|
110
|
+
undef_method :super_included_method
|
111
|
+
end
|
112
|
+
|
113
|
+
class Child2 < Parent
|
114
|
+
attr_reader :foo
|
115
|
+
end
|
116
|
+
|
117
|
+
# Be careful touching the Counts* classes as there used for testing
|
118
|
+
# private_instance_methods, public_instance_methods, etc. So adding, removing
|
119
|
+
# a method will break those tests.
|
120
|
+
module CountsMixin
|
121
|
+
def public_3; end
|
122
|
+
public :public_3
|
123
|
+
|
124
|
+
def private_3; end
|
125
|
+
private :private_3
|
126
|
+
|
127
|
+
def protected_3; end
|
128
|
+
protected :protected_3
|
129
|
+
end
|
130
|
+
|
131
|
+
class CountsParent
|
132
|
+
include CountsMixin
|
133
|
+
|
134
|
+
def public_2; end
|
135
|
+
|
136
|
+
private
|
137
|
+
def private_2; end
|
138
|
+
|
139
|
+
protected
|
140
|
+
def protected_2; end
|
141
|
+
end
|
142
|
+
|
143
|
+
class CountsChild < CountsParent
|
144
|
+
def public_1; end
|
145
|
+
|
146
|
+
private
|
147
|
+
def private_1; end
|
148
|
+
|
149
|
+
protected
|
150
|
+
def protected_1; end
|
151
|
+
end
|
152
|
+
|
153
|
+
module AddConstant
|
154
|
+
end
|
155
|
+
|
156
|
+
module A
|
157
|
+
CONSTANT_A = :a
|
158
|
+
OVERRIDE = :a
|
159
|
+
def ma(); :a; end
|
160
|
+
def self.cma(); :a; end
|
161
|
+
end
|
162
|
+
|
163
|
+
module B
|
164
|
+
CONSTANT_B = :b
|
165
|
+
OVERRIDE = :b
|
166
|
+
include A
|
167
|
+
def mb(); :b; end
|
168
|
+
def self.cmb(); :b; end
|
169
|
+
end
|
170
|
+
|
171
|
+
class C
|
172
|
+
OVERRIDE = :c
|
173
|
+
include B
|
174
|
+
end
|
175
|
+
|
176
|
+
module Z
|
177
|
+
MODULE_SPEC_TOPLEVEL_CONSTANT = 1
|
178
|
+
end
|
179
|
+
|
180
|
+
module Alias
|
181
|
+
def report() :report end
|
182
|
+
alias publish report
|
183
|
+
end
|
184
|
+
|
185
|
+
class Allonym
|
186
|
+
include ModuleSpecs::Alias
|
187
|
+
end
|
188
|
+
|
189
|
+
class Aliasing
|
190
|
+
def self.make_alias(*a)
|
191
|
+
alias_method(*a)
|
192
|
+
end
|
193
|
+
|
194
|
+
def public_one; 1; end
|
195
|
+
|
196
|
+
def public_two(n); n * 2; end
|
197
|
+
|
198
|
+
private
|
199
|
+
def private_one; 1; end
|
200
|
+
|
201
|
+
protected
|
202
|
+
def protected_one; 1; end
|
203
|
+
end
|
204
|
+
|
205
|
+
module AliasingSuper
|
206
|
+
|
207
|
+
module Parent
|
208
|
+
def super_call(arg)
|
209
|
+
arg
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
module Child
|
214
|
+
include Parent
|
215
|
+
def super_call(arg)
|
216
|
+
super(arg)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
class Target
|
221
|
+
include Child
|
222
|
+
alias_method :alias_super_call, :super_call
|
223
|
+
alias_method :super_call, :alias_super_call
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
|
228
|
+
module ReopeningModule
|
229
|
+
def foo; true; end
|
230
|
+
# module_function :foo
|
231
|
+
private :foo
|
232
|
+
end
|
233
|
+
|
234
|
+
# Yes, we want to re-open the module
|
235
|
+
module ReopeningModule
|
236
|
+
alias :foo2 :foo
|
237
|
+
# module_function :foo2
|
238
|
+
end
|
239
|
+
|
240
|
+
module Nesting
|
241
|
+
@tests = {}
|
242
|
+
def self.[](name); @tests[name]; end
|
243
|
+
def self.[]=(name, val); @tests[name] = val; end
|
244
|
+
def self.meta; class << self; self; end; end
|
245
|
+
|
246
|
+
# Nesting[:basic] = Module.nesting
|
247
|
+
|
248
|
+
module ::ModuleSpecs
|
249
|
+
# Nesting[:open_first_level] = Module.nesting
|
250
|
+
end
|
251
|
+
|
252
|
+
class << self
|
253
|
+
# Nesting[:open_meta] = Module.nesting
|
254
|
+
end
|
255
|
+
|
256
|
+
def self.called_from_module_method
|
257
|
+
# Module.nesting
|
258
|
+
end
|
259
|
+
|
260
|
+
class NestedClass
|
261
|
+
# Nesting[:nest_class] = Module.nesting
|
262
|
+
|
263
|
+
def self.called_from_class_method
|
264
|
+
# Module.nesting
|
265
|
+
end
|
266
|
+
|
267
|
+
def called_from_inst_method
|
268
|
+
# Module.nesting
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
273
|
+
|
274
|
+
# Nesting[:first_level] = Module.nesting
|
275
|
+
|
276
|
+
module InstanceMethMod
|
277
|
+
def bar(); :bar; end
|
278
|
+
end
|
279
|
+
|
280
|
+
class InstanceMeth
|
281
|
+
include InstanceMethMod
|
282
|
+
def foo(); :foo; end
|
283
|
+
end
|
284
|
+
|
285
|
+
class InstanceMethChild < InstanceMeth
|
286
|
+
end
|
287
|
+
|
288
|
+
module ClassVars
|
289
|
+
class A
|
290
|
+
@@a_cvar = :a_cvar
|
291
|
+
end
|
292
|
+
|
293
|
+
module M
|
294
|
+
@@m_cvar = :m_cvar
|
295
|
+
end
|
296
|
+
|
297
|
+
class B < A
|
298
|
+
include M
|
299
|
+
|
300
|
+
@@b_cvar = :b_cvar
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
class CVars
|
305
|
+
@@cls = :class
|
306
|
+
|
307
|
+
class << self
|
308
|
+
def cls
|
309
|
+
@@cls
|
310
|
+
end
|
311
|
+
@@meta = :meta
|
312
|
+
end
|
313
|
+
|
314
|
+
def self.meta
|
315
|
+
@@meta
|
316
|
+
end
|
317
|
+
|
318
|
+
def meta
|
319
|
+
@@meta
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
module MVars
|
324
|
+
@@mvar = :mvar
|
325
|
+
end
|
326
|
+
|
327
|
+
class SubModule < Module
|
328
|
+
attr_reader :special
|
329
|
+
def initialize
|
330
|
+
@special = 10
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
module MA; end
|
335
|
+
module MB
|
336
|
+
include MA
|
337
|
+
end
|
338
|
+
module MC; end
|
339
|
+
|
340
|
+
class MultipleIncludes
|
341
|
+
include MB
|
342
|
+
end
|
343
|
+
|
344
|
+
# empty modules
|
345
|
+
module M1; end
|
346
|
+
module M2; end
|
347
|
+
|
348
|
+
module Autoload
|
349
|
+
def self.use_ex1
|
350
|
+
begin
|
351
|
+
begin
|
352
|
+
raise "test exception"
|
353
|
+
rescue ModuleSpecs::Autoload::EX1
|
354
|
+
end
|
355
|
+
rescue RuntimeError
|
356
|
+
return :good
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
# This class isn't inherited from or included in anywhere. It exists to test
|
362
|
+
# 1.9's constant scoping rules
|
363
|
+
class Detached
|
364
|
+
DETATCHED_CONSTANT = :d
|
365
|
+
end
|
366
|
+
|
367
|
+
class ParentPrivateMethodRedef
|
368
|
+
private
|
369
|
+
def private_method_redefined
|
370
|
+
:before_redefinition
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
class ChildPrivateMethodMadePublic < ParentPrivateMethodRedef
|
375
|
+
public :private_method_redefined
|
376
|
+
end
|
377
|
+
|
378
|
+
class ParentPrivateMethodRedef
|
379
|
+
def private_method_redefined
|
380
|
+
:after_redefinition
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
module CyclicAppendA
|
385
|
+
end
|
386
|
+
|
387
|
+
module CyclicAppendB
|
388
|
+
include CyclicAppendA
|
389
|
+
end
|
390
|
+
|
391
|
+
module ExtendObject
|
392
|
+
C = :test
|
393
|
+
def test_method
|
394
|
+
"hello test"
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
module ExtendObjectPrivate
|
399
|
+
class << self
|
400
|
+
def extend_object(obj)
|
401
|
+
ScratchPad.record :extended
|
402
|
+
end
|
403
|
+
private :extend_object
|
404
|
+
end
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
class Object
|
409
|
+
def module_specs_public_method_on_object; end
|
410
|
+
|
411
|
+
def module_specs_private_method_on_object; end
|
412
|
+
private :module_specs_private_method_on_object
|
413
|
+
|
414
|
+
def module_specs_protected_method_on_object; end
|
415
|
+
protected :module_specs_private_method_on_object
|
416
|
+
|
417
|
+
def module_specs_private_method_on_object_for_kernel_public; end
|
418
|
+
private :module_specs_private_method_on_object_for_kernel_public
|
419
|
+
|
420
|
+
def module_specs_public_method_on_object_for_kernel_protected; end
|
421
|
+
def module_specs_public_method_on_object_for_kernel_private; end
|
422
|
+
end
|
423
|
+
|
424
|
+
module Kernel
|
425
|
+
def module_specs_public_method_on_kernel; end
|
426
|
+
|
427
|
+
alias_method :module_specs_alias_on_kernel, :module_specs_public_method_on_object
|
428
|
+
|
429
|
+
public :module_specs_private_method_on_object_for_kernel_public
|
430
|
+
protected :module_specs_public_method_on_object_for_kernel_protected
|
431
|
+
private :module_specs_public_method_on_object_for_kernel_private
|
432
|
+
end
|
433
|
+
|
434
|
+
# ModuleSpecs::Nesting[:root_level] = Module.nesting
|