def test_scope_of_global():
    """Make sure the scope of a global is the entire program."""
    js = """a = 0;"""
    ast = parse(js)
    raise SkipTest
    assignment = first(assignments(ast))
    eq_(assignment.scope_of(assignment['left']['name'])['type'], 'Program')
示例#2
0
def test_scope_of_initialized_variable():
    js = """function smoo() {
                var a = 0;
            }"""
    ast = parse(js)
    assignment = first(assignments(ast))
    eq_(assignment.scope_of(assignment['id']['name'])['id']['name'], 'smoo')
示例#3
0
def test_scope_of_global():
    """Make sure the scope of a global is the entire program."""
    js = """a = 0;"""
    ast = parse(js)
    raise SkipTest
    assignment = first(assignments(ast))
    eq_(assignment.scope_of(assignment["left"]["name"])["type"], "Program")
示例#4
0
def test_scope_of_initialized_variable():
    js = """function smoo() {
                var a = 0;
            }"""
    ast = parse(js)
    assignment = first(assignments(ast))
    eq_(scope_of(assignment["id"]["name"], assignment)["id"]["name"], "smoo")
示例#5
0
def test_scope_of_initialized_variable():
    js = """function smoo() {
                var a = 0;
            }"""
    ast = parse(js)
    assignment = first(assignments(ast))
    eq_(assignment.scope_of(assignment['id']['name'])['id']['name'], 'smoo')
示例#6
0
def test_scope_of_global_function():
    js = """function smoo() {
                var a;
                a = 0;
            }"""
    ast = parse(js)
    assignment = first(assignments(ast))
    eq_(assignment.scope_of(assignment['left']['name'])['type'], 'FunctionDeclaration')
示例#7
0
def test_scope_of_global_function():
    js = """function smoo() {
                var a;
                a = 0;
            }"""
    ast = parse(js)
    assignment = first(assignments(ast))
    eq_(scope_of(assignment["left"]["name"], assignment)["type"], "FunctionDeclaration")
示例#8
0
def test_scope_of_inner_function():
    js = """function smoo() {
                function bar() {
                    a = 0;
                }
            }"""
    ast = parse(js)
    assignment = first(assignments(ast))
    eq_(assignment.scope_of(assignment['left']['name'])['type'], 'Program')
示例#9
0
def test_scope_of_inner_function():
    js = """function smoo() {
                function bar() {
                    a = 0;
                }
            }"""
    ast = parse(js)
    assignment = first(assignments(ast))
    eq_(assignment.scope_of(assignment['left']['name'])['type'], 'Program')
示例#10
0
def test_scope_of_inner_function():
    js = """function smoo() {
                function bar() {
                    a = 0;
                }
            }"""
    ast = parse(js)
    assignment = first(assignments(ast))
    eq_(scope_of(assignment["left"]["name"], assignment)["type"], "Program")
示例#11
0
def test_scope_of_global_function():
    js = """function smoo() {
                var a;
                a = 0;
            }"""
    ast = parse(js)
    assignment = first(assignments(ast))
    eq_(
        assignment.scope_of(assignment['left']['name'])['type'],
        'FunctionDeclaration')
示例#12
0
def test_assignments():
    js = """a = 8;
            b = a;

            function c() {
                var d;
                d = a;
            }"""
    eq_([(a['left']['name'], a['right'].get('name', a['right'].get('value')))
         for a in assignments(parse(js))], [('a', 8), ('b', 'a'), ('d', 'a')])
def test_scope_of_inner_function():
    js = """function smoo() {
                function bar() {
                    var a;
                    a = 0;
                }
            }"""
    ast = parse(js)
    raise SkipTest
    assignment = first(assignments(ast))
    eq_(assignment.scope_of(assignment['left']['name'])['id']['name'], 'bar')
示例#14
0
def test_scope_of_inner_reference():
    js = """function smoo() {
                var a;

                function bar() {
                    a = 0;
                }
            }"""
    ast = parse(js)
    assignment = first(assignments(ast))
    eq_(assignment.scope_of(assignment['left']['name'])['id']['name'], 'smoo')
示例#15
0
def test_scope_of_inner_function():
    js = """function smoo() {
                function bar() {
                    var a;
                    a = 0;
                }
            }"""
    ast = parse(js)
    raise SkipTest
    assignment = first(assignments(ast))
    eq_(assignment.scope_of(assignment["left"]["name"])["id"]["name"], "bar")
示例#16
0
def test_scope_of_inner_reference():
    js = """function smoo() {
                var a;

                function bar() {
                    a = 0;
                }
            }"""
    ast = parse(js)
    assignment = first(assignments(ast))
    eq_(assignment.scope_of(assignment['left']['name'])['id']['name'], 'smoo')
示例#17
0
def test_scope_of_inner_reference():
    js = """function smoo() {
                var a;

                function bar() {
                    a = 0;
                }
            }"""
    ast = parse(js)
    assignment = first(assignments(ast))
    eq_(scope_of(assignment["left"]["name"], assignment)["id"]["name"], "smoo")
示例#18
0
def test_assignments():
    js = """a = 8;
            b = a;

            function c() {
                var d;
                d = a;
            }"""
    eq_([(a['left']['name'],
          a['right'].get('name', a['right'].get('value'))) for a in
         assignments(parse(js))],
        [('a', 8), ('b', 'a'), ('d', 'a')])
示例#19
0
def test_assignments():
    js = """a = 8;
            b = a;

            function c() {
                var d;
                d = a;
            }"""
    raise SkipTest
    eq_(
        [(a["left"]["name"], a["right"].get("name", a["right"].get("value"))) for a in assignments(parse(js))],
        [("a", 8), ("b", "a"), ("d", "a")],
    )
示例#20
0
def test_scope_of_global():
    """Make sure the scope of a global is the entire program."""
    js = """a = 0;"""
    ast = parse(js)
    assignment = first(assignments(ast))
    eq_(assignment.scope_of(assignment['left']['name'])['type'], 'Program')