rkelly 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +7 -0
- data/Manifest.txt +199 -0
- data/README.txt +58 -0
- data/Rakefile +85 -0
- data/lib/parser.y +870 -0
- data/lib/rkelly.rb +13 -0
- data/lib/rkelly/constants.rb +3 -0
- data/lib/rkelly/generated_parser.rb +3237 -0
- data/lib/rkelly/js.rb +14 -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/lexeme.rb +18 -0
- data/lib/rkelly/nodes.rb +5 -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 +88 -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/parser.rb +100 -0
- data/lib/rkelly/runtime.rb +36 -0
- data/lib/rkelly/runtime/ruby_function.rb +13 -0
- data/lib/rkelly/runtime/scope_chain.rb +57 -0
- data/lib/rkelly/token.rb +15 -0
- data/lib/rkelly/tokenizer.rb +122 -0
- data/lib/rkelly/visitable.rb +16 -0
- data/lib/rkelly/visitors.rb +4 -0
- data/lib/rkelly/visitors/dot_visitor.rb +228 -0
- data/lib/rkelly/visitors/ecma_visitor.rb +314 -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/rkelly.gemspec +33 -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_comma_node.rb +13 -0
- data/test/test_comments.rb +44 -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 +192 -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 +23 -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 +1355 -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 +143 -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 +390 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Expressions_11_4_5_Test < ECMAScriptTestCase
|
4
|
+
def test_uninitialized
|
5
|
+
@runtime.execute("
|
6
|
+
var MYVAR;
|
7
|
+
assert_equal(NaN, --MYVAR);
|
8
|
+
assert_equal(NaN, MYVAR);
|
9
|
+
")
|
10
|
+
end
|
11
|
+
|
12
|
+
@@tests = [
|
13
|
+
:undefined => ['(void 0)', 'NaN'],
|
14
|
+
:null => ['null', '-1'],
|
15
|
+
:true => ['true', '0'],
|
16
|
+
:false => ['false', '-1'],
|
17
|
+
:positive_infinity => ['Number.POSITIVE_INFINITY',
|
18
|
+
'Number.POSITIVE_INFINITY'],
|
19
|
+
:negative_infinity => ['Number.NEGATIVE_INFINITY',
|
20
|
+
'Number.NEGATIVE_INFINITY'],
|
21
|
+
:nan => ['Number.NaN', 'Number.NaN'],
|
22
|
+
:zero => ['0', '-1'],
|
23
|
+
#:pos_float => ['0.2345', '1.2345'],
|
24
|
+
#:neg_float => ['-0.2345', '0.7655'],
|
25
|
+
:boolean_false => ['new Boolean(false)', '-1'],
|
26
|
+
:boolean_true => ['new Boolean(true)', '0'],
|
27
|
+
:string_string => ["'string'", 'Number.NaN'],
|
28
|
+
:number_s => ["'12345'", '12344'],
|
29
|
+
:negative_s => ["'-12345'", '-12346'],
|
30
|
+
:hex_s => ["'0Xf'", '14'],
|
31
|
+
:num_0_s => ["'077'", '76'],
|
32
|
+
:empty_s => ["''", '-1'],
|
33
|
+
:obj_string_string => ['new String("string")', 'Number.NaN'],
|
34
|
+
:obj_string_num => ['new String("12345")', '12344'],
|
35
|
+
:obj_negative => ['new String("-12345")', '-12346'],
|
36
|
+
:obj_hex => ['new String("0Xf")', '14'],
|
37
|
+
:obj_0_s => ['new String("077")', '76'],
|
38
|
+
:obj_empty => ['new String("")', '-1'],
|
39
|
+
]
|
40
|
+
|
41
|
+
def test_positive_float
|
42
|
+
@runtime.execute("
|
43
|
+
var MYVAR=0.2345;
|
44
|
+
assert_in_delta(-0.7655, --MYVAR, 0.00001);
|
45
|
+
assert_in_delta(-0.7655, MYVAR, 0.00001);
|
46
|
+
")
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_negative_float
|
50
|
+
@runtime.execute("
|
51
|
+
var MYVAR=-0.2345;
|
52
|
+
assert_in_delta(-1.2345, --MYVAR, 0.00001);
|
53
|
+
assert_in_delta(-1.2345, MYVAR, 0.00001);
|
54
|
+
")
|
55
|
+
end
|
56
|
+
|
57
|
+
@@tests.each do |testing|
|
58
|
+
testing.each do |name, values|
|
59
|
+
define_method(:"test_#{name}") do
|
60
|
+
@runtime.execute("
|
61
|
+
var MYVAR=#{values[0]};
|
62
|
+
assert_equal(#{values[1]}, --MYVAR);
|
63
|
+
assert_equal(#{values[1]}, MYVAR);
|
64
|
+
")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Expressions_11_4_6_Test < ECMAScriptTestCase
|
4
|
+
@@tests = {
|
5
|
+
:empty_string => ["''", 0],
|
6
|
+
:space_string => ["' '", 0],
|
7
|
+
:tab_string => ["'\t'", 0],
|
8
|
+
:newline_string => ["'\n'", 0],
|
9
|
+
:cr_string => ["'\r'", 0],
|
10
|
+
:f_string => ["'\f'", 0],
|
11
|
+
:char_code_09 => ['String.fromCharCode(0x0009)', 0],
|
12
|
+
:char_code_20 => ['String.fromCharCode(0x0020)', 0],
|
13
|
+
:char_code_0C => ['String.fromCharCode(0x000C)', 0],
|
14
|
+
:char_code_0B => ['String.fromCharCode(0x000B)', 0],
|
15
|
+
:char_code_0A => ['String.fromCharCode(0x000A)', 0],
|
16
|
+
:lh_space_add => ["' ' + 999", 999],
|
17
|
+
:lh_newline_add => ["'\n' + 999", 999],
|
18
|
+
:lh_cr_add => ["'\r' + 999", 999],
|
19
|
+
:lh_tab_add => ["'\t' + 999", 999],
|
20
|
+
:lh_tab_f => ["'\f' + 999", 999],
|
21
|
+
:rh_space_add => ["999 + ' '", 999],
|
22
|
+
:rh_newline_add => ["999 + '\n'", 999],
|
23
|
+
:rh_cr_add => ["999 + '\r'", 999],
|
24
|
+
:rh_tab_add => ["999 + '\t'", 999],
|
25
|
+
:rh_tab_f => ["999 + '\f'", 999],
|
26
|
+
:bs_space_add => ["' ' + 999 + ' '", 999],
|
27
|
+
:bs_newline_add => ["'\n' + 999 + '\n'", 999],
|
28
|
+
:bs_cr_add => ["'\r' + 999 + '\r'", 999],
|
29
|
+
:bs_tab_add => ["'\t' + 999 + '\t'", 999],
|
30
|
+
:bs_tab_f => ["'\f' + 999 + '\f'", 999],
|
31
|
+
:cl_09 => ["String.fromCharCode(0x0009) + 99", 99],
|
32
|
+
:cl_20 => ["String.fromCharCode(0x0020) + 99", 99],
|
33
|
+
:cl_0C => ["String.fromCharCode(0x000C) + 99", 99],
|
34
|
+
:cl_0B => ["String.fromCharCode(0x000B) + 99", 99],
|
35
|
+
:cl_0A => ["String.fromCharCode(0x000A) + 99", 99],
|
36
|
+
:cr_09 => ["99 + String.fromCharCode(0x0009)", 99],
|
37
|
+
:cr_20 => ["99 + String.fromCharCode(0x0020)", 99],
|
38
|
+
:cr_0C => ["99 + String.fromCharCode(0x000C)", 99],
|
39
|
+
:cr_0B => ["99 + String.fromCharCode(0x000B)", 99],
|
40
|
+
:cr_0A => ["99 + String.fromCharCode(0x000A)", 99],
|
41
|
+
:bs_09 => ["String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", 99],
|
42
|
+
:bs_20 => ["String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", 99],
|
43
|
+
:bs_0C => ["String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", 99],
|
44
|
+
:bs_0B => ["String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", 99],
|
45
|
+
:bs_0A => ["String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", 99],
|
46
|
+
:infinity => ["'Infinity'", 'Number.POSITIVE_INFINITY'],
|
47
|
+
:neg_infinity => ["'-Infinity'", 'Number.NEGATIVE_INFINITY'],
|
48
|
+
:pos_infinity => ["'+Infinity'", 'Number.POSITIVE_INFINITY'],
|
49
|
+
}
|
50
|
+
@@sign_tests = [
|
51
|
+
[3.14159, 3.14159],
|
52
|
+
['3.', 3],
|
53
|
+
['3.e1', 30],
|
54
|
+
['3.e+1', 30],
|
55
|
+
['3.e-1', 0.30],
|
56
|
+
['.00001', 0.00001],
|
57
|
+
['.01e2', 1],
|
58
|
+
['.01e+2', 1],
|
59
|
+
['.01e-2', 0.0001],
|
60
|
+
['1234e5', 123400000],
|
61
|
+
['1234e+5', 123400000],
|
62
|
+
['1234e-5', 0.01234],
|
63
|
+
]
|
64
|
+
0.upto(9) { |x| @@sign_tests << [x, x] }
|
65
|
+
0.upto(15) { |x|
|
66
|
+
@@sign_tests << [sprintf("%#x", x), x]
|
67
|
+
@@sign_tests << [sprintf("%#x", x).gsub(/x/, 'X'), x]
|
68
|
+
if sprintf("%#x", x) =~ /[a-f]/
|
69
|
+
@@sign_tests << [sprintf("%#x", x).gsub(/([a-f])/) { |m| m.upcase }, x]
|
70
|
+
@@sign_tests << [sprintf("%#x", x).upcase, x]
|
71
|
+
end
|
72
|
+
}
|
73
|
+
@@sign_tests.each { |actual, expected|
|
74
|
+
define_method(:"test_num_#{actual.to_s.gsub(/[\.+]/, '_')}") do
|
75
|
+
@runtime.execute("
|
76
|
+
assert_equal(#{expected}, +('#{actual}'));
|
77
|
+
assert_equal(#{expected}, +('+#{actual}'));
|
78
|
+
assert_equal(-#{expected}, +('-#{actual}'));
|
79
|
+
")
|
80
|
+
end
|
81
|
+
}
|
82
|
+
|
83
|
+
@@tests.each do |name,(actual, expected)|
|
84
|
+
define_method(:"test_#{name}") do
|
85
|
+
@runtime.execute("assert_equal(#{expected}, +(#{actual}));")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Expressions_11_4_8_Test < ECMAScriptTestCase
|
4
|
+
def test_positive_not
|
5
|
+
0.upto(34) do |number|
|
6
|
+
js_assert_equal(~to_int_32(2 ** number), "~#{2 ** number}")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_negative_not
|
11
|
+
0.upto(34) do |number|
|
12
|
+
js_assert_equal(~to_int_32(-(2 ** number)), "~(#{-(2 ** number)})")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_int_32(value)
|
17
|
+
return value if value == 0
|
18
|
+
if value.respond_to?(:nan?) && (value.nan? || value.infinite?)
|
19
|
+
return 0
|
20
|
+
end
|
21
|
+
value = ((value < 0 ? -1 : 1) * value.abs.floor) % (2 ** 32)
|
22
|
+
if value >= 2 ** 31
|
23
|
+
value - (2 ** 32)
|
24
|
+
else
|
25
|
+
value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Expressions_11_4_9_Test < ECMAScriptTestCase
|
4
|
+
def test_not_null
|
5
|
+
js_assert_equal("true", "!(null)")
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_undefined
|
9
|
+
js_assert_equal("true", "!(void 0)")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_false
|
13
|
+
js_assert_equal("true", "!(false)")
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_true
|
17
|
+
js_assert_equal("false", "!(true)")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_zero
|
21
|
+
js_assert_equal("true", "!(0)")
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_negative_zero
|
25
|
+
js_assert_equal("true", "!(-0)")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_nan
|
29
|
+
js_assert_equal("true", "!(NaN)")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_infinity
|
33
|
+
js_assert_equal("false", "!(Infinity)")
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_negative_infinity
|
37
|
+
js_assert_equal("false", "!(-Infinity)")
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_math_pi
|
41
|
+
js_assert_equal("false", "!(Math.PI)")
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_1
|
45
|
+
js_assert_equal("false", "!(1)")
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_negative_1
|
49
|
+
js_assert_equal("false", "!(-1)")
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_empty_string
|
53
|
+
js_assert_equal("true", "!('')")
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_non_empty_string
|
57
|
+
js_assert_equal("false", "!('a string')")
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_empty_string_object
|
61
|
+
js_assert_equal("false", "!(new String(''))")
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_non_empty_string_object
|
65
|
+
js_assert_equal("false", "!(new String('string'))")
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_string_object
|
69
|
+
js_assert_equal("false", "!(new String())")
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_boolean_object
|
73
|
+
js_assert_equal("false", "!(new Boolean(true))")
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_false_boolean_object
|
77
|
+
js_assert_equal("false", "!(new Boolean(false))")
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_array_object
|
81
|
+
js_assert_equal("false", "!(new Array())")
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_stuff_in_array_object
|
85
|
+
js_assert_equal("false", "!(new Array(1,2,3))")
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_number_object
|
89
|
+
js_assert_equal("false", "!(new Number())")
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_number_object_0
|
93
|
+
js_assert_equal("false", "!(new Number(0))")
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_number_object_nan
|
97
|
+
js_assert_equal("false", "!(new Number(NaN))")
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_number_object_infinite
|
101
|
+
js_assert_equal("false", "!(new Number(Infinity))")
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Expressions_11_5_1_Test < ECMAScriptTestCase
|
4
|
+
def test_nan_times_nan
|
5
|
+
js_assert_equal("Number.NaN", "Number.NaN * Number.NaN")
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_nan_times_1
|
9
|
+
js_assert_equal("Number.NaN", "Number.NaN * 1")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_nan_1_times
|
13
|
+
js_assert_equal("Number.NaN", "1 * Number.NaN")
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_positive_inf_times_0
|
17
|
+
js_assert_equal("Number.NaN", "Number.POSITIVE_INFINITY * 0")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_negative_inf_times_0
|
21
|
+
js_assert_equal("Number.NaN", "Number.NEGATIVE_INFINITY * 0")
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_0_times_positive_inf
|
25
|
+
js_assert_equal("Number.NaN", "0 * Number.POSITIVE_INFINITY")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_0_times_negative_inf
|
29
|
+
js_assert_equal("Number.NaN", "0 * Number.NEGATIVE_INFINITY")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_0_times_0
|
33
|
+
js_assert_equal("0", "0 * 0")
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_infinity_multiplication
|
37
|
+
js_assert_equal("Number.POSITIVE_INFINITY", "Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY")
|
38
|
+
js_assert_equal("Number.NEGATIVE_INFINITY", "Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY")
|
39
|
+
js_assert_equal("Number.NEGATIVE_INFINITY", "Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY")
|
40
|
+
js_assert_equal("Number.POSITIVE_INFINITY", "Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY")
|
41
|
+
js_assert_equal("Number.NEGATIVE_INFINITY", "Number.NEGATIVE_INFINITY * 1")
|
42
|
+
js_assert_equal("Number.POSITIVE_INFINITY", "Number.NEGATIVE_INFINITY * -1")
|
43
|
+
js_assert_equal("Number.NEGATIVE_INFINITY", "1 * Number.NEGATIVE_INFINITY")
|
44
|
+
js_assert_equal("Number.POSITIVE_INFINITY", "-1 * Number.NEGATIVE_INFINITY")
|
45
|
+
js_assert_equal("Number.POSITIVE_INFINITY", "Number.POSITIVE_INFINITY * 1")
|
46
|
+
js_assert_equal("Number.NEGATIVE_INFINITY", "Number.POSITIVE_INFINITY * -1")
|
47
|
+
js_assert_equal("Number.POSITIVE_INFINITY", "1 * Number.POSITIVE_INFINITY")
|
48
|
+
js_assert_equal("Number.NEGATIVE_INFINITY", "-1 * Number.POSITIVE_INFINITY")
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helper"
|
2
|
+
|
3
|
+
class Expressions_11_5_2_Test < ECMAScriptTestCase
|
4
|
+
def test_nan_divide
|
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
|
+
|
13
|
+
def test_infinity_divided_by_infinity
|
14
|
+
js_assert_equal("Number.NaN", "Number.NEGATIVE_INFINITY / Number.NEGATIVE_INFINITY")
|
15
|
+
js_assert_equal("Number.NaN", "Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY")
|
16
|
+
js_assert_equal("Number.NaN", "Number.NEGATIVE_INFINITY / Number.POSITIVE_INFINITY")
|
17
|
+
js_assert_equal("Number.NaN", "Number.POSITIVE_INFINITY / Number.POSITIVE_INFINITY")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_infinity_divided_by_0
|
21
|
+
js_assert_equal("Number.POSITIVE_INFINITY", "Number.POSITIVE_INFINITY / 0")
|
22
|
+
js_assert_equal("Number.NEGATIVE_INFINITY", "Number.NEGATIVE_INFINITY / 0")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_infinity_divided_by_1
|
26
|
+
js_assert_equal("Number.NEGATIVE_INFINITY", "Number.NEGATIVE_INFINITY / 1")
|
27
|
+
js_assert_equal("Number.POSITIVE_INFINITY", "Number.NEGATIVE_INFINITY / -1")
|
28
|
+
js_assert_equal("Number.POSITIVE_INFINITY", "Number.POSITIVE_INFINITY / 1")
|
29
|
+
js_assert_equal("Number.NEGATIVE_INFINITY", "Number.POSITIVE_INFINITY / -1")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_infinity_divided_by_max
|
33
|
+
js_assert_equal("Number.NEGATIVE_INFINITY","Number.NEGATIVE_INFINITY / Number.MAX_VALUE")
|
34
|
+
js_assert_equal("Number.POSITIVE_INFINITY","Number.NEGATIVE_INFINITY / -Number.MAX_VALUE")
|
35
|
+
js_assert_equal("Number.POSITIVE_INFINITY","Number.POSITIVE_INFINITY / Number.MAX_VALUE")
|
36
|
+
js_assert_equal("Number.NEGATIVE_INFINITY","Number.POSITIVE_INFINITY / -Number.MAX_VALUE")
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_number_divided_by_infinity
|
40
|
+
js_assert_equal("-0", "1 / Number.NEGATIVE_INFINITY")
|
41
|
+
js_assert_equal("0", "1 / Number.POSITIVE_INFINITY")
|
42
|
+
js_assert_equal("-0", "-1 / Number.POSITIVE_INFINITY")
|
43
|
+
js_assert_equal("0", "-1 / Number.NEGATIVE_INFINITY")
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_max_val_divided_by_infinity
|
47
|
+
js_assert_equal("-0", "Number.MAX_VALUE / Number.NEGATIVE_INFINITY")
|
48
|
+
js_assert_equal("0", "Number.MAX_VALUE / Number.POSITIVE_INFINITY")
|
49
|
+
js_assert_equal("-0", "-Number.MAX_VALUE / Number.POSITIVE_INFINITY")
|
50
|
+
js_assert_equal("0", "-Number.MAX_VALUE / Number.NEGATIVE_INFINITY")
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_0_divide_by_0
|
54
|
+
js_assert_equal("Number.NaN", "0 / -0")
|
55
|
+
js_assert_equal("Number.NaN", "-0 / 0")
|
56
|
+
js_assert_equal("Number.NaN", "-0 / -0")
|
57
|
+
js_assert_equal("Number.NaN", "0 / 0")
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_0_divide_by_number
|
61
|
+
js_assert_equal("0", "0 / 1")
|
62
|
+
js_assert_equal("-0", "0 / -1")
|
63
|
+
js_assert_equal("-0", "-0 / 1")
|
64
|
+
js_assert_equal("0", "-0 / -1")
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_number_divide_by_0
|
68
|
+
js_assert_equal("Number.POSITIVE_INFINITY", "1/0")
|
69
|
+
js_assert_equal("Number.NEGATIVE_INFINITY", "1/-0")
|
70
|
+
js_assert_equal("Number.NEGATIVE_INFINITY", "-1/0")
|
71
|
+
js_assert_equal("Number.POSITIVE_INFINITY", "-1/-0")
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_0_divide_by_infinity
|
75
|
+
js_assert_equal("0", "0 / Number.POSITIVE_INFINITY")
|
76
|
+
js_assert_equal("-0", "0 / Number.NEGATIVE_INFINITY")
|
77
|
+
js_assert_equal("-0", "-0 / Number.POSITIVE_INFINITY")
|
78
|
+
js_assert_equal("0", "-0 / Number.NEGATIVE_INFINITY")
|
79
|
+
end
|
80
|
+
end
|
@@ -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
|