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')