opal 0.3.27 → 0.3.28
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/CONTRIBUTING.md +24 -0
- data/README.md +6 -5
- data/Rakefile +12 -2
- data/core/array.rb +3 -31
- data/core/enumerable.rb +32 -4
- data/core/hash.rb +218 -186
- data/core/json.rb +3 -2
- data/core/kernel.rb +28 -28
- data/core/numeric.rb +2 -2
- data/core/runtime.js +0 -1
- data/lib/opal.rb +4 -2
- data/lib/opal/grammar.rb +6 -2
- data/lib/opal/grammar.y +3 -0
- data/lib/opal/lexer.rb +25 -10
- data/lib/opal/parser.rb +75 -34
- data/lib/opal/scope.rb +7 -7
- data/lib/opal/version.rb +1 -1
- data/opal.gemspec +1 -1
- data/spec/core/array/reduce_spec.rb +31 -0
- data/spec/{opal → core}/array/to_json_spec.rb +0 -0
- data/spec/core/boolean/and_spec.rb +17 -0
- data/spec/core/boolean/inspect_spec.rb +9 -0
- data/spec/core/boolean/or_spec.rb +17 -0
- data/spec/{opal → core}/boolean/singleton_class_spec.rb +0 -0
- data/spec/{opal → core}/boolean/to_json_spec.rb +1 -1
- data/spec/core/boolean/to_s_spec.rb +9 -0
- data/spec/core/boolean/xor_spec.rb +17 -0
- data/spec/{opal → core}/class/bridge_class_spec.rb +0 -0
- data/spec/{opal → core}/class/instance_methods_spec.rb +0 -0
- data/spec/core/class/last_value_spec.rb +68 -0
- data/spec/core/enumerable/detect_spec.rb +1 -1
- data/spec/core/enumerable/find_spec.rb +1 -1
- data/spec/{opal → core}/hash/to_json_spec.rb +0 -0
- data/spec/{opal → core}/hash/to_native_spec.rb +0 -0
- data/spec/{opal → core}/json/parse_spec.rb +0 -0
- data/spec/core/kernel/block_given.rb +30 -0
- data/spec/core/kernel/methods_spec.rb +11 -0
- data/spec/core/kernel/p_spec.rb +13 -0
- data/spec/{opal → core}/kernel/to_json_spec.rb +0 -0
- data/spec/{opal → core}/nil/to_json_spec.rb +0 -0
- data/spec/core/numeric/abs_spec.rb +12 -0
- data/spec/core/numeric/bit_and_spec.rb +7 -0
- data/spec/core/numeric/bit_or_spec.rb +8 -0
- data/spec/core/numeric/bit_xor_spec.rb +6 -0
- data/spec/core/numeric/ceil_spec.rb +8 -0
- data/spec/core/numeric/chr_spec.rb +8 -0
- data/spec/core/numeric/comparison_spec.rb +24 -0
- data/spec/core/numeric/complement_spec.rb +8 -0
- data/spec/core/numeric/divide_spec.rb +10 -0
- data/spec/core/numeric/downto_spec.rb +19 -0
- data/spec/core/numeric/eql_spec.rb +9 -0
- data/spec/core/numeric/even_spec.rb +21 -0
- data/spec/core/numeric/exponent_spec.rb +33 -0
- data/spec/core/numeric/floor_spec.rb +8 -0
- data/spec/core/numeric/gt_spec.rb +11 -0
- data/spec/core/numeric/gte_spec.rb +12 -0
- data/spec/core/numeric/integer_spec.rb +9 -0
- data/spec/core/numeric/left_shift_spec.rb +21 -0
- data/spec/core/numeric/lt_spec.rb +11 -0
- data/spec/core/numeric/lte_spec.rb +12 -0
- data/spec/core/numeric/magnitude_spec.rb +12 -0
- data/spec/core/numeric/minus_spec.rb +8 -0
- data/spec/core/numeric/modulo_spec.rb +19 -0
- data/spec/core/numeric/multiply_spec.rb +9 -0
- data/spec/core/numeric/next_spec.rb +9 -0
- data/spec/core/numeric/odd_spec.rb +21 -0
- data/spec/core/numeric/ord_spec.rb +9 -0
- data/spec/core/numeric/plus_spec.rb +8 -0
- data/spec/core/numeric/pred_spec.rb +7 -0
- data/spec/core/numeric/right_shift_spec.rb +25 -0
- data/spec/core/numeric/succ_spec.rb +9 -0
- data/spec/core/numeric/times_spec.rb +36 -0
- data/spec/core/numeric/to_f_spec.rb +7 -0
- data/spec/core/numeric/to_i_spec.rb +7 -0
- data/spec/{opal → core}/numeric/to_json_spec.rb +0 -0
- data/spec/core/numeric/to_s_spec.rb +8 -0
- data/spec/core/numeric/uminus_spec.rb +9 -0
- data/spec/core/numeric/upto_spec.rb +19 -0
- data/spec/core/numeric/zero_spec.rb +7 -0
- data/spec/{opal → core}/runtime/call_spec.rb +0 -0
- data/spec/{opal → core}/runtime/class_hierarchy_spec.rb +0 -0
- data/spec/{opal → core}/runtime/def_spec.rb +0 -0
- data/spec/{opal → core}/runtime/defined_spec.rb +0 -0
- data/spec/{opal → core}/runtime/super_spec.rb +0 -0
- data/spec/{opal → core}/string/demodulize_spec.rb +0 -0
- data/spec/{opal → core}/string/to_json_spec.rb +0 -0
- data/spec/{opal → core}/string/underscore_spec.rb +0 -0
- data/spec/{opal → core}/strscan/check_spec.rb +0 -0
- data/spec/{opal → core}/strscan/scan_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/alias_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/and_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/array_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/attrasgn_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/begin_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/block_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/break_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/call_spec.rb +23 -1
- data/spec/{lib/grammar → grammar}/class_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/const_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/cvar_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/def_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/false_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/file_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/gvar_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/hash_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/iasgn_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/if_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/iter_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/ivar_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/lambda_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/lasgn_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/line_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/lvar_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/masgn_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/module_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/nil_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/not_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/op_asgn1_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/op_asgn2_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/or_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/return_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/sclass_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/self_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/str_spec.rb +7 -0
- data/spec/{lib/grammar → grammar}/super_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/true_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/undef_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/unless_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/while_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/xstr_spec.rb +0 -0
- data/spec/{lib/grammar → grammar}/yield_spec.rb +0 -0
- data/spec/language/string_spec.rb +5 -0
- data/spec/{lib/parser → parser}/simple_spec.rb +0 -0
- metadata +231 -159
- data/spec/core/false/and_spec.rb +0 -9
- data/spec/core/false/inspect_spec.rb +0 -5
- data/spec/core/false/or_spec.rb +0 -9
- data/spec/core/false/to_s_spec.rb +0 -5
- data/spec/core/false/xor_spec.rb +0 -9
- data/spec/core/true/and_spec.rb +0 -9
- data/spec/core/true/inspect_spec.rb +0 -5
- data/spec/core/true/or_spec.rb +0 -9
- data/spec/core/true/to_s_spec.rb +0 -5
- data/spec/core/true/xor_spec.rb +0 -9
- data/spec/lib/erb_parser/simple.erb +0 -1
- data/spec/opal/kernel/attribute_spec.rb +0 -57
- data/spec/opal/runtime/method_missing_spec.rb +0 -17
data/spec/core/false/and_spec.rb
DELETED
data/spec/core/false/or_spec.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
describe "FalseClass#|" do
|
2
|
-
it "returns false if other is nil or false, otherwise true" do
|
3
|
-
(false | false).should == false
|
4
|
-
(false | true).should == true
|
5
|
-
(false | nil).should == false
|
6
|
-
(false | "").should == true
|
7
|
-
(false | mock('x')).should == true
|
8
|
-
end
|
9
|
-
end
|
data/spec/core/false/xor_spec.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
describe "FalseClass#^" do
|
2
|
-
it "returns false if other is nil or false, otherwise true" do
|
3
|
-
(false ^ false).should == false
|
4
|
-
(false ^ true).should == true
|
5
|
-
(false ^ nil).should == false
|
6
|
-
(false ^ "").should == true
|
7
|
-
(false ^ mock('x')).should == true
|
8
|
-
end
|
9
|
-
end
|
data/spec/core/true/and_spec.rb
DELETED
data/spec/core/true/or_spec.rb
DELETED
data/spec/core/true/to_s_spec.rb
DELETED
data/spec/core/true/xor_spec.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Hello world
|
@@ -1,57 +0,0 @@
|
|
1
|
-
class AttributeSpec
|
2
|
-
attr_accessor :foo, :bar
|
3
|
-
attr_reader :first_name, :baz
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@foo = 'adam'
|
7
|
-
@bar = 42
|
8
|
-
@baz = 3.142
|
9
|
-
@buz = 'omg'
|
10
|
-
end
|
11
|
-
|
12
|
-
def baz?
|
13
|
-
'should not return this one'
|
14
|
-
end
|
15
|
-
|
16
|
-
def buz?
|
17
|
-
@buz
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe Kernel do
|
22
|
-
before do
|
23
|
-
@obj = AttributeSpec.new
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#attribute_get" do
|
27
|
-
it "returns attribute values for simple keys" do
|
28
|
-
@obj.attribute_get(:foo).should == 'adam'
|
29
|
-
@obj.attribute_get(:bar).should == 42
|
30
|
-
end
|
31
|
-
|
32
|
-
it "checks for boolean (foo?) accessors after normal getters" do
|
33
|
-
@obj.attribute_get(:baz).should == 3.142
|
34
|
-
@obj.attribute_get(:buz).should == 'omg'
|
35
|
-
end
|
36
|
-
|
37
|
-
it "returns nil for unknown attributes" do
|
38
|
-
@obj.attribute_get(:fullname).should be_nil
|
39
|
-
@obj.attribute_get(:pingpong).should be_nil
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "#attribute_set" do
|
44
|
-
it "uses the setter for the given attribute" do
|
45
|
-
@obj.attribute_set(:foo, 42)
|
46
|
-
@obj.foo.should == 42
|
47
|
-
|
48
|
-
@obj.attribute_set(:foo, 3.142)
|
49
|
-
@obj.foo.should == 3.142
|
50
|
-
end
|
51
|
-
|
52
|
-
it "returns nil when setting an attribute with no setter method" do
|
53
|
-
@obj.attribute_set(:baz, 'this should not be set')
|
54
|
-
@obj.baz.should == 3.142
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class MethodMissingSpec
|
2
|
-
def method_missing(method, *args)
|
3
|
-
[method, args]
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
describe "method_missing" do
|
8
|
-
before do
|
9
|
-
@object = MethodMissingSpec.new
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should be called for all missing methods" do
|
13
|
-
# @object.foo.should == ['foo', []]
|
14
|
-
# @object.bar(10).should == ['bar', [10]]
|
15
|
-
# (@object.title = 100).should == ['title=', [100]]
|
16
|
-
end
|
17
|
-
end
|