rkelly-remix 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/CHANGELOG.rdoc +9 -0
- data/Manifest.txt +203 -0
- data/README.rdoc +58 -0
- data/Rakefile +39 -0
- data/lib/parser.y +871 -0
- data/lib/rkelly/char_pos.rb +35 -0
- data/lib/rkelly/char_range.rb +31 -0
- data/lib/rkelly/constants.rb +3 -0
- data/lib/rkelly/generated_parser.rb +3217 -0
- data/lib/rkelly/js/array.rb +15 -0
- data/lib/rkelly/js/base.rb +91 -0
- data/lib/rkelly/js/boolean.rb +21 -0
- data/lib/rkelly/js/function.rb +39 -0
- data/lib/rkelly/js/function_prototype.rb +15 -0
- data/lib/rkelly/js/global_object.rb +52 -0
- data/lib/rkelly/js/math.rb +10 -0
- data/lib/rkelly/js/nan.rb +18 -0
- data/lib/rkelly/js/number.rb +22 -0
- data/lib/rkelly/js/object.rb +30 -0
- data/lib/rkelly/js/object_prototype.rb +14 -0
- data/lib/rkelly/js/property.rb +20 -0
- data/lib/rkelly/js/scope.rb +6 -0
- data/lib/rkelly/js/string.rb +21 -0
- data/lib/rkelly/js.rb +14 -0
- data/lib/rkelly/lexeme.rb +18 -0
- data/lib/rkelly/nodes/binary_node.rb +18 -0
- data/lib/rkelly/nodes/bracket_accessor_node.rb +11 -0
- data/lib/rkelly/nodes/case_clause_node.rb +11 -0
- data/lib/rkelly/nodes/comma_node.rb +11 -0
- data/lib/rkelly/nodes/conditional_node.rb +11 -0
- data/lib/rkelly/nodes/dot_accessor_node.rb +11 -0
- data/lib/rkelly/nodes/for_in_node.rb +12 -0
- data/lib/rkelly/nodes/for_node.rb +13 -0
- data/lib/rkelly/nodes/function_call_node.rb +16 -0
- data/lib/rkelly/nodes/function_decl_node.rb +6 -0
- data/lib/rkelly/nodes/function_expr_node.rb +12 -0
- data/lib/rkelly/nodes/if_node.rb +12 -0
- data/lib/rkelly/nodes/label_node.rb +11 -0
- data/lib/rkelly/nodes/new_expr_node.rb +11 -0
- data/lib/rkelly/nodes/node.rb +94 -0
- data/lib/rkelly/nodes/not_strict_equal_node.rb +6 -0
- data/lib/rkelly/nodes/op_equal_node.rb +16 -0
- data/lib/rkelly/nodes/postfix_node.rb +11 -0
- data/lib/rkelly/nodes/prefix_node.rb +6 -0
- data/lib/rkelly/nodes/property_node.rb +13 -0
- data/lib/rkelly/nodes/resolve_node.rb +19 -0
- data/lib/rkelly/nodes/strict_equal_node.rb +6 -0
- data/lib/rkelly/nodes/try_node.rb +13 -0
- data/lib/rkelly/nodes/var_decl_node.rb +15 -0
- data/lib/rkelly/nodes.rb +25 -0
- data/lib/rkelly/parser.rb +89 -0
- data/lib/rkelly/runtime/ruby_function.rb +13 -0
- data/lib/rkelly/runtime/scope_chain.rb +57 -0
- data/lib/rkelly/runtime.rb +36 -0
- data/lib/rkelly/syntax_error.rb +4 -0
- data/lib/rkelly/token.rb +24 -0
- data/lib/rkelly/tokenizer.rb +193 -0
- data/lib/rkelly/visitable.rb +16 -0
- data/lib/rkelly/visitors/dot_visitor.rb +228 -0
- data/lib/rkelly/visitors/ecma_visitor.rb +322 -0
- data/lib/rkelly/visitors/enumerable_visitor.rb +18 -0
- data/lib/rkelly/visitors/evaluation_visitor.rb +419 -0
- data/lib/rkelly/visitors/function_visitor.rb +46 -0
- data/lib/rkelly/visitors/pointcut_visitor.rb +31 -0
- data/lib/rkelly/visitors/real_sexp_visitor.rb +16 -0
- data/lib/rkelly/visitors/sexp_visitor.rb +373 -0
- data/lib/rkelly/visitors/visitor.rb +136 -0
- data/lib/rkelly/visitors.rb +4 -0
- data/lib/rkelly.rb +14 -0
- data/test/ecma_script_test_case.rb +21 -0
- data/test/execute_test_case.rb +16 -0
- data/test/execution_contexts/test_10_1_3-1.rb +32 -0
- data/test/expressions/test_11_3_1.rb +64 -0
- data/test/expressions/test_11_3_2.rb +64 -0
- data/test/expressions/test_11_4_2.rb +13 -0
- data/test/expressions/test_11_4_3.rb +52 -0
- data/test/expressions/test_11_4_4.rb +68 -0
- data/test/expressions/test_11_4_5.rb +69 -0
- data/test/expressions/test_11_4_6.rb +88 -0
- data/test/expressions/test_11_4_8.rb +28 -0
- data/test/expressions/test_11_4_9.rb +103 -0
- data/test/expressions/test_11_5_1.rb +51 -0
- data/test/expressions/test_11_5_2.rb +80 -0
- data/test/expressions/test_11_5_3.rb +88 -0
- data/test/expressions/test_11_6_1-1.rb +19 -0
- data/test/expressions/test_11_9_1.rb +19 -0
- data/test/function/test_15_3_1_1-1.rb +34 -0
- data/test/global_object/test_15_1_1_1.rb +29 -0
- data/test/global_object/test_15_1_1_2.rb +17 -0
- data/test/global_object/test_15_1_1_3.rb +9 -0
- data/test/helper.rb +5 -0
- data/test/node_test_case.rb +11 -0
- data/test/object/test_15_2_1_1.rb +257 -0
- data/test/object/test_15_2_1_2.rb +21 -0
- data/test/object/test_15_2_2_1.rb +52 -0
- data/test/statements/test_12_5-1.rb +27 -0
- data/test/test_add_node.rb +8 -0
- data/test/test_arguments_node.rb +8 -0
- data/test/test_array_node.rb +9 -0
- data/test/test_assign_expr_node.rb +8 -0
- data/test/test_automatic_semicolon_insertion.rb +137 -0
- data/test/test_bit_and_node.rb +8 -0
- data/test/test_bit_or_node.rb +8 -0
- data/test/test_bit_x_or_node.rb +8 -0
- data/test/test_bitwise_not_node.rb +8 -0
- data/test/test_block_node.rb +14 -0
- data/test/test_bracket_accessor_node.rb +16 -0
- data/test/test_break_node.rb +11 -0
- data/test/test_case_block_node.rb +11 -0
- data/test/test_case_clause_node.rb +15 -0
- data/test/test_char_pos.rb +39 -0
- data/test/test_char_range.rb +29 -0
- data/test/test_comma_node.rb +13 -0
- data/test/test_comments.rb +45 -0
- data/test/test_conditional_node.rb +17 -0
- data/test/test_const_statement_node.rb +14 -0
- data/test/test_continue_node.rb +11 -0
- data/test/test_delete_node.rb +8 -0
- data/test/test_divide_node.rb +8 -0
- data/test/test_do_while_node.rb +13 -0
- data/test/test_dot_accessor_node.rb +9 -0
- data/test/test_ecma_visitor.rb +210 -0
- data/test/test_element_node.rb +8 -0
- data/test/test_empty_statement_node.rb +8 -0
- data/test/test_equal_node.rb +8 -0
- data/test/test_evaluation_visitor.rb +66 -0
- data/test/test_expression_statement_node.rb +10 -0
- data/test/test_false_node.rb +8 -0
- data/test/test_for_in_node.rb +17 -0
- data/test/test_for_node.rb +24 -0
- data/test/test_function_body_node.rb +8 -0
- data/test/test_function_call_node.rb +10 -0
- data/test/test_function_decl_node.rb +16 -0
- data/test/test_function_expr_node.rb +16 -0
- data/test/test_function_visitor.rb +26 -0
- data/test/test_getter_property_node.rb +10 -0
- data/test/test_global_object.rb +49 -0
- data/test/test_greater_node.rb +8 -0
- data/test/test_greater_or_equal_node.rb +8 -0
- data/test/test_if_node.rb +17 -0
- data/test/test_in_node.rb +8 -0
- data/test/test_instance_of_node.rb +8 -0
- data/test/test_label_node.rb +13 -0
- data/test/test_left_shift_node.rb +8 -0
- data/test/test_less_node.rb +8 -0
- data/test/test_less_or_equal_node.rb +8 -0
- data/test/test_line_number.rb +81 -0
- data/test/test_logical_and_node.rb +8 -0
- data/test/test_logical_not_node.rb +8 -0
- data/test/test_logical_or_node.rb +8 -0
- data/test/test_modulus_node.rb +8 -0
- data/test/test_multiply_node.rb +8 -0
- data/test/test_new_expr_node.rb +9 -0
- data/test/test_not_equal_node.rb +8 -0
- data/test/test_not_strict_equal_node.rb +8 -0
- data/test/test_null_node.rb +8 -0
- data/test/test_number_node.rb +8 -0
- data/test/test_object_literal_node.rb +9 -0
- data/test/test_op_and_equal_node.rb +10 -0
- data/test/test_op_divide_equal_node.rb +10 -0
- data/test/test_op_equal_node.rb +10 -0
- data/test/test_op_l_shift_equal_node.rb +10 -0
- data/test/test_op_minus_equal_node.rb +10 -0
- data/test/test_op_mod_equal_node.rb +10 -0
- data/test/test_op_multiply_equal_node.rb +10 -0
- data/test/test_op_or_equal_node.rb +10 -0
- data/test/test_op_plus_equal_node.rb +10 -0
- data/test/test_op_r_shift_equal_node.rb +10 -0
- data/test/test_op_u_r_shift_equal_node.rb +10 -0
- data/test/test_op_x_or_equal_node.rb +10 -0
- data/test/test_parameter_node.rb +8 -0
- data/test/test_parser.rb +1361 -0
- data/test/test_pointcut_visitor.rb +34 -0
- data/test/test_postfix_node.rb +8 -0
- data/test/test_prefix_node.rb +8 -0
- data/test/test_property_node.rb +8 -0
- data/test/test_regexp_node.rb +8 -0
- data/test/test_resolve_node.rb +22 -0
- data/test/test_return_node.rb +11 -0
- data/test/test_right_shift_node.rb +8 -0
- data/test/test_rkelly.rb +19 -0
- data/test/test_runtime.rb +12 -0
- data/test/test_scope_chain.rb +50 -0
- data/test/test_setter_property_node.rb +10 -0
- data/test/test_source_elements.rb +9 -0
- data/test/test_strict_equal_node.rb +8 -0
- data/test/test_string_node.rb +8 -0
- data/test/test_subtract_node.rb +8 -0
- data/test/test_switch_node.rb +12 -0
- data/test/test_this_node.rb +8 -0
- data/test/test_throw_node.rb +7 -0
- data/test/test_tokenizer.rb +209 -0
- data/test/test_true_node.rb +8 -0
- data/test/test_try_node.rb +59 -0
- data/test/test_type_of_node.rb +8 -0
- data/test/test_unary_minus_node.rb +8 -0
- data/test/test_unary_plus_node.rb +8 -0
- data/test/test_unsigned_right_shift_node.rb +8 -0
- data/test/test_var_decl_node.rb +21 -0
- data/test/test_var_statement_node.rb +14 -0
- data/test/test_void_node.rb +8 -0
- data/test/test_while_node.rb +15 -0
- data/test/test_with_node.rb +8 -0
- metadata +432 -0
@@ -0,0 +1,88 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Expressions_11_5_3_Test < ECMAScriptTestCase
|
4
|
+
def test_either_is_nan
|
5
|
+
js_assert_equal("Number.NaN", "Number.NaN % Number.NaN")
|
6
|
+
js_assert_equal("Number.NaN", "Number.NaN % 1")
|
7
|
+
js_assert_equal("Number.NaN", "1 % Number.NaN")
|
8
|
+
js_assert_equal("Number.NaN", "Number.POSITIVE_INFINITY % Number.NaN")
|
9
|
+
js_assert_equal("Number.NaN", "Number.NEGATIVE_INFINITY % Number.NaN")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_infinity_mod_infinity
|
13
|
+
js_assert_equal("Number.NaN", "Number.NEGATIVE_INFINITY % Number.NEGATIVE_INFINITY")
|
14
|
+
js_assert_equal("Number.NaN", "Number.POSITIVE_INFINITY % Number.NEGATIVE_INFINITY")
|
15
|
+
js_assert_equal("Number.NaN", "Number.NEGATIVE_INFINITY % Number.POSITIVE_INFINITY")
|
16
|
+
js_assert_equal("Number.NaN", "Number.POSITIVE_INFINITY % Number.POSITIVE_INFINITY")
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_infinity_mod_0
|
20
|
+
js_assert_equal("Number.NaN", "Number.POSITIVE_INFINITY % 0")
|
21
|
+
js_assert_equal("Number.NaN", "Number.NEGATIVE_INFINITY % 0")
|
22
|
+
js_assert_equal("Number.NaN", "Number.POSITIVE_INFINITY % -0")
|
23
|
+
js_assert_equal("Number.NaN", "Number.NEGATIVE_INFINITY % -0")
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_infinity_mod_1
|
27
|
+
js_assert_equal("Number.NaN", "Number.NEGATIVE_INFINITY % 1")
|
28
|
+
js_assert_equal("Number.NaN", "Number.NEGATIVE_INFINITY % -1")
|
29
|
+
js_assert_equal("Number.NaN", "Number.POSITIVE_INFINITY % 1")
|
30
|
+
js_assert_equal("Number.NaN", "Number.POSITIVE_INFINITY % -1")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_infinity_mod_max_value
|
34
|
+
js_assert_equal("Number.NaN", "Number.NEGATIVE_INFINITY % Number.MAX_VALUE")
|
35
|
+
js_assert_equal("Number.NaN", "Number.NEGATIVE_INFINITY % -Number.MAX_VALUE")
|
36
|
+
js_assert_equal("Number.NaN", "Number.POSITIVE_INFINITY % Number.MAX_VALUE")
|
37
|
+
js_assert_equal("Number.NaN", "Number.POSITIVE_INFINITY % -Number.MAX_VALUE")
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_0_mod_0
|
41
|
+
js_assert_equal("Number.NaN", "0 % -0")
|
42
|
+
js_assert_equal("Number.NaN", "-0 % 0")
|
43
|
+
js_assert_equal("Number.NaN", "-0 % -0")
|
44
|
+
js_assert_equal("Number.NaN", "0 % 0")
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_1_mod_0
|
48
|
+
js_assert_equal("Number.NaN", "1%0")
|
49
|
+
js_assert_equal("Number.NaN", "1%-0")
|
50
|
+
js_assert_equal("Number.NaN", "-1%0")
|
51
|
+
js_assert_equal("Number.NaN", "-1%-0")
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_max_value_mod_0
|
55
|
+
js_assert_equal("Number.NaN", "Number.MAX_VALUE%0")
|
56
|
+
js_assert_equal("Number.NaN", "Number.MAX_VALUE%-0")
|
57
|
+
js_assert_equal("Number.NaN", "-Number.MAX_VALUE%0")
|
58
|
+
js_assert_equal("Number.NaN", "-Number.MAX_VALUE%-0")
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_number_mod_infinity
|
62
|
+
js_assert_equal("1", "1 % Number.NEGATIVE_INFINITY")
|
63
|
+
js_assert_equal("1", "1 % Number.POSITIVE_INFINITY")
|
64
|
+
js_assert_equal("-1", "-1 % Number.POSITIVE_INFINITY")
|
65
|
+
js_assert_equal("-1", "-1 % Number.NEGATIVE_INFINITY")
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_max_val_mod_infinity
|
69
|
+
js_assert_equal("Number.MAX_VALUE", "Number.MAX_VALUE % Number.NEGATIVE_INFINITY")
|
70
|
+
js_assert_equal("Number.MAX_VALUE", "Number.MAX_VALUE % Number.POSITIVE_INFINITY")
|
71
|
+
js_assert_equal("-Number.MAX_VALUE", "-Number.MAX_VALUE % Number.POSITIVE_INFINITY")
|
72
|
+
js_assert_equal("-Number.MAX_VALUE", "-Number.MAX_VALUE % Number.NEGATIVE_INFINITY")
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_0_mod_infinity
|
76
|
+
js_assert_equal("0", "0 % Number.POSITIVE_INFINITY")
|
77
|
+
js_assert_equal("0", "0 % Number.NEGATIVE_INFINITY")
|
78
|
+
js_assert_equal("-0", "-0 % Number.POSITIVE_INFINITY")
|
79
|
+
js_assert_equal("-0", "-0 % Number.NEGATIVE_INFINITY")
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_0_mod_1
|
83
|
+
js_assert_equal("0", "0 % 1")
|
84
|
+
js_assert_equal("-0", "0 % -1")
|
85
|
+
js_assert_equal("-0", "-0 % 1")
|
86
|
+
js_assert_equal("0", "-0 % -1")
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Expressions_11_6_1_1_Test < ECMAScriptTestCase
|
4
|
+
def test_primitive_boolean
|
5
|
+
js_assert_equal("1", "true + false")
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_boolean_object
|
9
|
+
js_assert_equal("1", "new Boolean(true) + new Boolean(false)")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_object_boolean_object
|
13
|
+
js_assert_equal("1", "new Object(true) + new Object(false)")
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_object_boolean_object_boolean
|
17
|
+
js_assert_equal("1", "new Object(new Boolean(true)) + new Object(new Boolean(false))")
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Expressions_11_9_1_Test < ExecuteTestCase
|
4
|
+
def setup
|
5
|
+
@runtime = RKelly::Runtime.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_void_equal
|
9
|
+
assert_execute({ 'x' => true }, "var x = void(0) == void(0);")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_void_equal_decl
|
13
|
+
assert_execute({ 'z' => true }, "var x = 10; var y = 10; var z = x == y;")
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_null_eql
|
17
|
+
assert_execute({ 'x' => true }, "var x = null == null;")
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Functions_15_3_1_1_1_Test < ECMAScriptTestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@runtime.execute(<<END
|
7
|
+
var MyObject = Function( "value", "this.value = value; this.valueOf = Function( 'return this.value' ); this.toString = Function( 'return String(this.value
|
8
|
+
);' )" );
|
9
|
+
var myfunc = Function();
|
10
|
+
myfunc.toString = Object.prototype.toString;
|
11
|
+
END
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_to_string
|
16
|
+
js_assert_equal("'[object Function]'", "myfunc.toString()")
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_length
|
20
|
+
js_assert_equal("0", "myfunc.length")
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_prototype_to_string
|
24
|
+
js_assert_equal("'[object Object]'", "myfunc.prototype.toString()")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_prototype_constructor
|
28
|
+
js_assert_equal("myfunc", "myfunc.prototype.constructor")
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_arguments
|
32
|
+
js_assert_equal("null", "myfunc.arguments")
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
# ECMA-262
|
4
|
+
# Section 15.1.1.1
|
5
|
+
class GlobalObject_15_1_1_1_Test < ECMAScriptTestCase
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
@object = GlobalObject.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_nan
|
12
|
+
assert @object.has_property?('NaN')
|
13
|
+
assert @object['NaN'].dont_enum?
|
14
|
+
assert @object['NaN'].dont_delete?
|
15
|
+
assert @object['NaN'].value.nan?
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_global_nan
|
19
|
+
js_assert_equal('Number.NaN', 'NaN')
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_this_nan
|
23
|
+
js_assert_equal('Number.NaN', 'this.NaN')
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_typeof_nan
|
27
|
+
js_assert_equal("'number'", 'typeof NaN')
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
# ECMA-262
|
4
|
+
# Section 15.1.1.2
|
5
|
+
class GlobalObject_15_1_1_2_Test < ECMAScriptTestCase
|
6
|
+
def test_global_nan
|
7
|
+
js_assert_equal('Number.POSITIVE_INFINITY', 'Infinity')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_this_nan
|
11
|
+
js_assert_equal('Number.POSITIVE_INFINITY', 'this.Infinity')
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_typeof_nan
|
15
|
+
js_assert_equal("'number'", 'typeof Infinity')
|
16
|
+
end
|
17
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,257 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Object_15_2_1_1_Test < ECMAScriptTestCase
|
4
|
+
def test_null_value_of
|
5
|
+
@runtime.execute("
|
6
|
+
var NULL_OBJECT = Object(null);
|
7
|
+
assert_equal(NULL_OBJECT, (NULL_OBJECT).valueOf());
|
8
|
+
")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_null_type_of
|
12
|
+
js_assert_equal("'object'", 'typeof (Object(null))')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_undefined_value_of
|
16
|
+
@runtime.execute("
|
17
|
+
var UNDEF_OBJECT = Object(void 0);
|
18
|
+
assert_equal(UNDEF_OBJECT, (UNDEF_OBJECT).valueOf());
|
19
|
+
")
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_undefined_type_of
|
23
|
+
js_assert_equal("'object'", 'typeof (Object(void 0))')
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_true_type_of
|
27
|
+
js_assert_equal("'object'", 'typeof (Object(true))')
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_true_value_of
|
31
|
+
js_assert_equal("true", 'Object(true).valueOf()')
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_true_to_string
|
35
|
+
@runtime.execute("
|
36
|
+
var MYOB = Object(true);
|
37
|
+
MYOB.toString = Object.prototype.toString;
|
38
|
+
assert_equal('[object Boolean]', MYOB.toString());
|
39
|
+
")
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_false_value_of
|
43
|
+
js_assert_equal("false", 'Object(false).valueOf()')
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_false_type_of
|
47
|
+
js_assert_equal("'object'", 'typeof (Object(false))')
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_false_to_string
|
51
|
+
@runtime.execute("
|
52
|
+
var MYOB = Object(false);
|
53
|
+
MYOB.toString = Object.prototype.toString;
|
54
|
+
assert_equal('[object Boolean]', MYOB.toString());
|
55
|
+
")
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_0_value_of
|
59
|
+
js_assert_equal("0", 'Object(0).valueOf()')
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_0_type_of
|
63
|
+
js_assert_equal("'object'", 'typeof Object(0)')
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_0_to_string
|
67
|
+
@runtime.execute("
|
68
|
+
var MYOB = Object(0);
|
69
|
+
MYOB.toString = Object.prototype.toString;
|
70
|
+
assert_equal('[object Number]', MYOB.toString());
|
71
|
+
")
|
72
|
+
end
|
73
|
+
|
74
|
+
# Diverts from the ECMA. In ECMA, -0 is -0, not 0
|
75
|
+
def test_minus_0_value_of
|
76
|
+
js_assert_equal("0", 'Object(-0).valueOf()')
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_minus_0_type_of
|
80
|
+
js_assert_equal("'object'", 'typeof Object(-0)')
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_minus_0_to_string
|
84
|
+
@runtime.execute("
|
85
|
+
var MYOB = Object(-0);
|
86
|
+
MYOB.toString = Object.prototype.toString;
|
87
|
+
assert_equal('[object Number]', MYOB.toString());
|
88
|
+
")
|
89
|
+
end
|
90
|
+
## END Diversion. ;-)
|
91
|
+
|
92
|
+
def test_1_value_of
|
93
|
+
js_assert_equal("1", 'Object(1).valueOf()')
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_1_type_of
|
97
|
+
js_assert_equal("'object'", 'typeof Object(1)')
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_1_to_string
|
101
|
+
@runtime.execute("
|
102
|
+
var MYOB = Object(1);
|
103
|
+
MYOB.toString = Object.prototype.toString;
|
104
|
+
assert_equal('[object Number]', MYOB.toString());
|
105
|
+
")
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_minus_1_value_of
|
109
|
+
js_assert_equal("-1", 'Object(-1).valueOf()')
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_minus_1_type_of
|
113
|
+
js_assert_equal("'object'", 'typeof Object(-1)')
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_minus_1_to_string
|
117
|
+
@runtime.execute("
|
118
|
+
var MYOB = Object(-1);
|
119
|
+
MYOB.toString = Object.prototype.toString;
|
120
|
+
assert_equal('[object Number]', MYOB.toString());
|
121
|
+
")
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_number_max_value_of
|
125
|
+
js_assert_equal("1.797693134862315e308", 'Object(Number.MAX_VALUE).valueOf()')
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_number_max_type_of
|
129
|
+
js_assert_equal("'object'", 'typeof Object(Number.MAX_VALUE)')
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_number_max_to_string
|
133
|
+
@runtime.execute("
|
134
|
+
var MYOB = Object(Number.MAX_VALUE);
|
135
|
+
MYOB.toString = Object.prototype.toString;
|
136
|
+
assert_equal('[object Number]', MYOB.toString());
|
137
|
+
")
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_number_min_value_of
|
141
|
+
js_assert_equal("1.0e-306", 'Object(Number.MIN_VALUE).valueOf()')
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_number_min_type_of
|
145
|
+
js_assert_equal("'object'", 'typeof Object(Number.MIN_VALUE)')
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_number_min_to_string
|
149
|
+
@runtime.execute("
|
150
|
+
var MYOB = Object(Number.MIN_VALUE);
|
151
|
+
MYOB.toString = Object.prototype.toString;
|
152
|
+
assert_equal('[object Number]', MYOB.toString());
|
153
|
+
")
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_number_positive_infinity_value
|
157
|
+
js_assert_equal(
|
158
|
+
"Number.POSITIVE_INFINITY",
|
159
|
+
'Object(Number.POSITIVE_INFINITY).valueOf()'
|
160
|
+
)
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_number_positive_infinity_type
|
164
|
+
js_assert_equal("'object'", 'typeof Object(Number.POSITIVE_INFINITY)')
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_number_positive_infinity_string
|
168
|
+
@runtime.execute("
|
169
|
+
var MYOB = Object(Number.POSITIVE_INFINITY);
|
170
|
+
MYOB.toString = Object.prototype.toString;
|
171
|
+
assert_equal('[object Number]', MYOB.toString());
|
172
|
+
")
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_number_negative_infinity_value
|
176
|
+
js_assert_equal(
|
177
|
+
"Number.NEGATIVE_INFINITY",
|
178
|
+
'Object(Number.NEGATIVE_INFINITY).valueOf()'
|
179
|
+
)
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_number_negative_infinity_type
|
183
|
+
js_assert_equal("'object'", 'typeof Object(Number.NEGATIVE_INFINITY)')
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_number_negative_infinity_string
|
187
|
+
@runtime.execute("
|
188
|
+
var MYOB = Object(Number.NEGATIVE_INFINITY);
|
189
|
+
MYOB.toString = Object.prototype.toString;
|
190
|
+
assert_equal('[object Number]', MYOB.toString());
|
191
|
+
")
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_nan_value
|
195
|
+
js_assert_equal("Number.NaN", 'Object(Number.NaN).valueOf()')
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_number_nan_type
|
199
|
+
js_assert_equal("'object'", 'typeof Object(Number.NaN)')
|
200
|
+
end
|
201
|
+
|
202
|
+
def test_number_nan_string
|
203
|
+
@runtime.execute("
|
204
|
+
var MYOB = Object(Number.NaN);
|
205
|
+
MYOB.toString = Object.prototype.toString;
|
206
|
+
assert_equal('[object Number]', MYOB.toString());
|
207
|
+
")
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_empty_string_value
|
211
|
+
js_assert_equal("''", 'Object("").valueOf()')
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_empty_string_type
|
215
|
+
js_assert_equal("'object'", 'typeof Object("")')
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_empty_string_to_string
|
219
|
+
@runtime.execute("
|
220
|
+
var MYOB = Object('');
|
221
|
+
MYOB.toString = Object.prototype.toString;
|
222
|
+
assert_equal('[object String]', MYOB.toString());
|
223
|
+
")
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_string_value
|
227
|
+
js_assert_equal("'a string'", 'Object("a string").valueOf()')
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_string_type
|
231
|
+
js_assert_equal("'object'", 'typeof Object("a string")')
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_string_to_string
|
235
|
+
@runtime.execute("
|
236
|
+
var MYOB = Object('a string');
|
237
|
+
MYOB.toString = Object.prototype.toString;
|
238
|
+
assert_equal('[object String]', MYOB.toString());
|
239
|
+
")
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_escape_string_value
|
243
|
+
js_assert_equal("'\r\t\b\n\v\f'", "Object('\r\t\b\n\v\f').valueOf()")
|
244
|
+
end
|
245
|
+
|
246
|
+
def test_escape_string_type
|
247
|
+
js_assert_equal("'object'", "typeof Object('\r\t\b\n\v\f')")
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_escape_string_to_string
|
251
|
+
@runtime.execute("
|
252
|
+
var MYOB = Object('\r\t\b\n\v\f');
|
253
|
+
MYOB.toString = Object.prototype.toString;
|
254
|
+
assert_equal('[object String]', MYOB.toString());
|
255
|
+
")
|
256
|
+
end
|
257
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Object_15_2_1_2_Test < ECMAScriptTestCase
|
4
|
+
def test_object_value_of
|
5
|
+
@runtime.execute("
|
6
|
+
var MYOB = Object();
|
7
|
+
assert_equal(MYOB, MYOB.valueOf());
|
8
|
+
")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_object_type_of
|
12
|
+
js_assert_equal("'object'", 'typeof Object()')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_object_to_string
|
16
|
+
@runtime.execute("
|
17
|
+
var MYOB = Object();
|
18
|
+
assert_equal('[object Object]', MYOB.toString());
|
19
|
+
")
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Object_15_2_2_1_Test < ECMAScriptTestCase
|
4
|
+
def test_null_typeof
|
5
|
+
js_assert_equal("'object'", "typeof new Object(null)")
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_null_to_string
|
9
|
+
js_assert_to_string('Object', 'null')
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_void_0_typeof
|
13
|
+
js_assert_equal("'object'", "typeof new Object(void 0)")
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_void_0_to_string
|
17
|
+
js_assert_to_string('Object', 'void 0')
|
18
|
+
end
|
19
|
+
|
20
|
+
@@tests = {
|
21
|
+
'minus_1' => ['-1', 'Number'],
|
22
|
+
'1' => ['1', 'Number'],
|
23
|
+
'minus_0' => ['-0', 'Number'],
|
24
|
+
'0' => ['0', 'Number'],
|
25
|
+
'nan' => ['Number.NaN', 'Number'],
|
26
|
+
'empty_string' => ['""', 'String'],
|
27
|
+
'string' => ['"string"', 'String'],
|
28
|
+
'true' => ['true', 'Boolean'],
|
29
|
+
'false' => ['false', 'Boolean'],
|
30
|
+
'boolean' => ['Boolean()', 'Boolean'],
|
31
|
+
}
|
32
|
+
|
33
|
+
@@tests.each do |name, info|
|
34
|
+
define_method(:"test_#{name}_typeof") do
|
35
|
+
js_assert_equal("'object'", "typeof new Object(#{info[0]})")
|
36
|
+
end
|
37
|
+
define_method(:"test_#{name}_valueof") do
|
38
|
+
js_assert_equal(info[0], "(new Object(#{info[0]})).valueOf()")
|
39
|
+
end
|
40
|
+
define_method(:"test_#{name}_tostring") do
|
41
|
+
js_assert_to_string(info[1], info[0])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def js_assert_to_string(expected_type, js_obj)
|
46
|
+
@runtime.execute("
|
47
|
+
MYOB = new Object(#{js_obj});
|
48
|
+
MYOB.toString = Object.prototype.toString;
|
49
|
+
assert_equal('[object #{expected_type}]', MYOB.toString());
|
50
|
+
")
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Statement_12_5_1_Test < ExecuteTestCase
|
4
|
+
def setup
|
5
|
+
@runtime = RKelly::Runtime.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_if_true
|
9
|
+
assert_execute({ 'x' => 'pass' },
|
10
|
+
"var x; if(true) x = 'pass'; else x = 'fail';")
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_if_false
|
14
|
+
assert_execute({ 'x' => 'pass' },
|
15
|
+
"var x; if(false) x = 'fail'; else x = 'pass';")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_if_zero
|
19
|
+
assert_execute({ 'x' => 'pass' },
|
20
|
+
"var x; if(0) x = 'fail'; else x = 'pass';")
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_if_one
|
24
|
+
assert_execute({ 'x' => 'pass' },
|
25
|
+
"var x; if(1) x = 'pass'; else x = 'fail';")
|
26
|
+
end
|
27
|
+
end
|