rkelly-turbo 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.rdoc +38 -0
- data/Manifest.txt +203 -0
- data/README.rdoc +135 -0
- data/Rakefile +41 -0
- data/lib/parser.y +883 -0
- data/lib/rkelly.rb +14 -0
- data/lib/rkelly/char_pos.rb +39 -0
- data/lib/rkelly/char_range.rb +33 -0
- data/lib/rkelly/constants.rb +3 -0
- data/lib/rkelly/generated_parser.rb +3380 -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 +25 -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 +116 -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 +106 -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/syntax_error.rb +4 -0
- data/lib/rkelly/token.rb +27 -0
- data/lib/rkelly/tokenizer.rb +255 -0
- data/lib/rkelly/visitable.rb +31 -0
- data/lib/rkelly/visitors.rb +4 -0
- data/lib/rkelly/visitors/dot_visitor.rb +228 -0
- data/lib/rkelly/visitors/ecma_visitor.rb +328 -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 +149 -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 +94 -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 +213 -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 +1434 -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 +285 -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 +293 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
2
|
+
|
3
|
+
class ForNodeTest < NodeTestCase
|
4
|
+
def test_failure
|
5
|
+
initializer = AssignExprNode.new(NumberNode.new(10))
|
6
|
+
decl = VarDeclNode.new('foo', initializer)
|
7
|
+
stmt = VarStatementNode.new([decl])
|
8
|
+
|
9
|
+
compare = LessNode.new(ResolveNode.new('foo'), NumberNode.new(10))
|
10
|
+
exec = PostfixNode.new(ResolveNode.new('foo'), '++')
|
11
|
+
|
12
|
+
block = BlockNode.new(SourceElementsNode.new([stmt]))
|
13
|
+
|
14
|
+
node = ForNode.new(nil, nil, nil, block)
|
15
|
+
assert_sexp([:for, nil, nil, nil, [:block, [[:var, [[:var_decl, :foo, [:assign, [:lit, 10]]]]]]]], node)
|
16
|
+
|
17
|
+
node = ForNode.new(stmt, compare, exec, block)
|
18
|
+
assert_sexp([:for,
|
19
|
+
[:var, [[:var_decl, :foo, [:assign, [:lit, 10]]]]],
|
20
|
+
[:less, [:resolve, 'foo'], [:lit, 10]],
|
21
|
+
[:postfix, [:resolve, 'foo'], '++'],
|
22
|
+
[:block, [[:var, [[:var_decl, :foo, [:assign, [:lit, 10]]]]]]]], node)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
2
|
+
|
3
|
+
class FunctionCallNodeTest < NodeTestCase
|
4
|
+
def test_to_sexp
|
5
|
+
resolve = ResolveNode.new('foo')
|
6
|
+
args = ArgumentsNode.new([])
|
7
|
+
node = FunctionCallNode.new(resolve, args)
|
8
|
+
assert_sexp([:function_call, [:resolve, 'foo'], [:args, []]], node)
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
2
|
+
|
3
|
+
class FunctionDeclNodeTest < NodeTestCase
|
4
|
+
def test_to_sexp
|
5
|
+
body = FunctionBodyNode.new(SourceElementsNode.new([]))
|
6
|
+
node = FunctionDeclNode.new(nil, body)
|
7
|
+
assert_sexp([:func_decl, nil, [], [:func_body, []]], node)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_to_sexp_with_args
|
11
|
+
body = FunctionBodyNode.new(SourceElementsNode.new([]))
|
12
|
+
node = FunctionDeclNode.new(nil, body, [ParameterNode.new('a')])
|
13
|
+
assert_sexp([:func_decl, nil, [[:param, 'a']], [:func_body, []]],
|
14
|
+
node)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
2
|
+
|
3
|
+
class FunctionExprNodeTest < NodeTestCase
|
4
|
+
def test_to_sexp
|
5
|
+
body = FunctionBodyNode.new(SourceElementsNode.new([]))
|
6
|
+
node = FunctionExprNode.new(nil, body)
|
7
|
+
assert_sexp([:func_expr, nil, [], [:func_body, []]], node)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_to_sexp_with_args
|
11
|
+
body = FunctionBodyNode.new(SourceElementsNode.new([]))
|
12
|
+
node = FunctionExprNode.new(nil, body, [ParameterNode.new('a')])
|
13
|
+
assert_sexp([:func_expr, nil, [[:param, 'a']], [:func_body, []]],
|
14
|
+
node)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
2
|
+
|
3
|
+
class FunctionVisitorTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@parser = RKelly::Parser.new
|
6
|
+
@scope = RKelly::Runtime::ScopeChain.new
|
7
|
+
@visitor = RKelly::Visitors::FunctionVisitor.new(@scope)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_function
|
11
|
+
tree = @parser.parse('function foo() { var x = 10; }')
|
12
|
+
@visitor.accept(tree)
|
13
|
+
assert @visitor.scope_chain['foo']
|
14
|
+
|
15
|
+
tree = @parser.parse('function foo() { var x = 10; function bar() {}; }')
|
16
|
+
@visitor.accept(tree)
|
17
|
+
assert @visitor.scope_chain['foo']
|
18
|
+
assert !@visitor.scope_chain.has_property?('bar')
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_function_call
|
22
|
+
tree = @parser.parse('var x = foo(); function foo() { return 10; }')
|
23
|
+
@visitor.accept(tree)
|
24
|
+
assert @visitor.scope_chain['foo']
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
2
|
+
|
3
|
+
class GetterPropertyNodeTest < NodeTestCase
|
4
|
+
def test_to_sexp
|
5
|
+
body = FunctionBodyNode.new(SourceElementsNode.new([]))
|
6
|
+
function = FunctionExprNode.new(nil, body)
|
7
|
+
node = GetterPropertyNode.new('foo', function)
|
8
|
+
assert_sexp([:getter, :foo, [:func_expr, nil, [], [:func_body, []]]], node)
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
2
|
+
|
3
|
+
class GlobalObjectTest < Test::Unit::TestCase
|
4
|
+
include RKelly::JS
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@object = GlobalObject.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_initialize
|
11
|
+
assert_equal :undefined, @object['prototype'].value
|
12
|
+
assert_equal 'GlobalObject', @object['class'].value
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_braces
|
16
|
+
@object['foo'] = 'blah'
|
17
|
+
assert @object.has_property?('foo')
|
18
|
+
assert @object['foo']
|
19
|
+
assert_equal('blah', @object['foo'].value)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_undefined_brace
|
23
|
+
#assert_equal :undefined, @object['foo'].value
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_delete
|
27
|
+
assert !@object.has_property?('foo')
|
28
|
+
@object['foo'] = 'blah'
|
29
|
+
assert @object.has_property?('foo')
|
30
|
+
assert @object.delete('foo')
|
31
|
+
assert !@object.has_property?('foo')
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_can_put
|
35
|
+
@object['foo'] = 'blah'
|
36
|
+
@object['foo'].attributes << :read_only
|
37
|
+
assert @object['foo'].read_only?
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_prototype
|
41
|
+
proto = GlobalObject.new
|
42
|
+
proto['foo'] = 'bar'
|
43
|
+
assert proto.has_property?('foo')
|
44
|
+
|
45
|
+
assert !@object.has_property?('foo')
|
46
|
+
@object['prototype'] = proto
|
47
|
+
assert @object.has_property?('foo')
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
2
|
+
|
3
|
+
class IfNodeTest < NodeTestCase
|
4
|
+
def test_to_sexp
|
5
|
+
initializer = AssignExprNode.new(NumberNode.new(20))
|
6
|
+
decl = VarDeclNode.new('foo', initializer)
|
7
|
+
stmt = VarStatementNode.new([decl])
|
8
|
+
and_node = LogicalAndNode.new(NumberNode.new(5), NumberNode.new(10))
|
9
|
+
node = IfNode.new(and_node, stmt)
|
10
|
+
|
11
|
+
assert_sexp([:if,
|
12
|
+
[:and, [:lit, 5], [:lit, 10]],
|
13
|
+
[:var, [[:var_decl, :foo, [:assign, [:lit, 20]]]]]],
|
14
|
+
node)
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
2
|
+
|
3
|
+
class LabelNodeTest < NodeTestCase
|
4
|
+
def test_to_sexp
|
5
|
+
initializer = AssignExprNode.new(NumberNode.new(10))
|
6
|
+
var = VarDeclNode.new('bar', initializer)
|
7
|
+
node = LabelNode.new('foo', var)
|
8
|
+
assert_sexp(
|
9
|
+
[:label, :foo,
|
10
|
+
[:var_decl, :bar, [:assign, [:lit, 10]]],
|
11
|
+
], node)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
2
|
+
|
3
|
+
class LineNumberTest < NodeTestCase
|
4
|
+
def test_line_numbers
|
5
|
+
parser = RKelly::Parser.new
|
6
|
+
ast = parser.parse(<<-eojs)
|
7
|
+
/**
|
8
|
+
* This is an awesome test comment.
|
9
|
+
*/
|
10
|
+
function aaron() {
|
11
|
+
var x = 10;
|
12
|
+
return 1 + 1;
|
13
|
+
}
|
14
|
+
eojs
|
15
|
+
func = ast.pointcut(FunctionDeclNode).matches.first
|
16
|
+
assert func
|
17
|
+
assert_equal(4, func.line)
|
18
|
+
|
19
|
+
return_node = ast.pointcut(ReturnNode).matches.first
|
20
|
+
assert return_node
|
21
|
+
assert_equal(6, return_node.line)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_ranges
|
25
|
+
parser = RKelly::Parser.new
|
26
|
+
ast = parser.parse(<<-eojs)
|
27
|
+
/**
|
28
|
+
* This is an awesome test comment.
|
29
|
+
*/
|
30
|
+
function aaron() {
|
31
|
+
var x = 10;
|
32
|
+
return 1 + 1;
|
33
|
+
}
|
34
|
+
eojs
|
35
|
+
func = ast.pointcut(FunctionDeclNode).matches.first
|
36
|
+
assert func
|
37
|
+
assert_equal("<{line:4 char:7 (68)}...{line:7 char:7 (135)}>", func.range.to_s)
|
38
|
+
|
39
|
+
return_node = ast.pointcut(ReturnNode).matches.first
|
40
|
+
assert return_node
|
41
|
+
assert_equal("<{line:6 char:9 (115)}...{line:6 char:21 (127)}>", return_node.range.to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_range_of_var_statement_with_semicolon
|
45
|
+
parser = RKelly::Parser.new
|
46
|
+
ast = parser.parse(<<-eojs)
|
47
|
+
var x = {
|
48
|
+
foo: 10,
|
49
|
+
bar: "blah"
|
50
|
+
};
|
51
|
+
eojs
|
52
|
+
stmt = ast.pointcut(VarStatementNode).matches.first
|
53
|
+
assert_equal("<{line:1 char:7 (6)}...{line:4 char:8 (60)}>", stmt.range.to_s)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_range_of_var_statement_without_semicolon
|
57
|
+
parser = RKelly::Parser.new
|
58
|
+
ast = parser.parse(<<-eojs)
|
59
|
+
var x = {
|
60
|
+
foo: 10,
|
61
|
+
bar: "blah"
|
62
|
+
}
|
63
|
+
eojs
|
64
|
+
stmt = ast.pointcut(VarStatementNode).matches.first
|
65
|
+
assert_equal("<{line:1 char:7 (6)}...{line:4 char:7 (59)}>", stmt.range.to_s)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_range_of_empty_function_body
|
69
|
+
parser = RKelly::Parser.new
|
70
|
+
ast = parser.parse(<<-eojs)
|
71
|
+
function f () {
|
72
|
+
}
|
73
|
+
eojs
|
74
|
+
|
75
|
+
stmt = ast.pointcut(FunctionDeclNode).matches.first
|
76
|
+
assert_equal("<{line:1 char:7 (6)}...{line:2 char:7 (28)}>", stmt.range.to_s)
|
77
|
+
|
78
|
+
stmt = ast.pointcut(FunctionBodyNode).matches.first
|
79
|
+
assert_equal("<{line:1 char:21 (20)}...{line:2 char:7 (28)}>", stmt.range.to_s)
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
2
|
+
|
3
|
+
class NewExprNodeTest < NodeTestCase
|
4
|
+
def test_to_sexp
|
5
|
+
resolve = ResolveNode.new('foo')
|
6
|
+
node = NewExprNode.new(resolve, ArgumentsNode.new([]))
|
7
|
+
assert_sexp([:new_expr, [:resolve, 'foo'], [:args, []]], node)
|
8
|
+
end
|
9
|
+
end
|