Package org.mozilla.javascript.ast

Examples of org.mozilla.javascript.ast.ExpressionStatement.toSource()


    private BranchStatementBuilder builder = new BranchStatementBuilder();

    @Test
    public void shouldBuildLineAndConditionInitialisation() {
        ExpressionStatement statement = builder.buildLineAndConditionInitialisation("test.js", 4, 2, 12, 15, "x < calc('7')");
        assertThat(statement.toSource(), equalTo("_$jscoverage['test.js'].branchData['4'][2].init(12, 15, 'x < calc(\\'7\\')');\n"));
    }

    @Test
    public void shouldRemoveInstrumentationFromSource() {
        assertThat(builder.removeInstrumentation("  _$jscoverage['/dir/code.js'].someOtherData[101]++;\n"), equalTo(""));
View Full Code Here


        ExpressionStatement statement = builder.buildLineAndConditionInitialisation("test.js", 4, 2, 12, 15,
                "  x++;\n" +
                "  _$jscoverage['/dir/code.js'].lineData[100]++;\n" +
                "  x++;\n" +
                "  _$jscoverage['/dir/code.js'].someOtherData[101]++;\n");
        assertThat(statement.toSource(), equalTo("_$jscoverage['test.js'].branchData['4'][2].init(12, 15, '  x++;\\n  x++;\\n');\n"));
    }

    @Test
    public void shouldBuildLineAndConditionCall() {
        ExpressionStatement statement = builder.buildLineAndConditionCall("test.js", 4, 2);
View Full Code Here

    }

    @Test
    public void shouldBuildLineAndConditionCall() {
        ExpressionStatement statement = builder.buildLineAndConditionCall("test.js", 4, 2);
        assertThat(statement.toSource(), equalTo("_$jscoverage['test.js'].branchData['4'][2].ranCondition(result);\n"));
    }

    @Test
    public void shouldBuildLineAndConditionRecordingFunction() {
        FunctionNode statement = builder.buildBranchRecordingFunction("test.js", 1, 4, 2);
View Full Code Here

    @Test
    public void shouldCreateInstrumentationStatement() {
        ExpressionStatement statement = builder.buildInstrumentationStatement(7, "/dir/file.js", validLines);

        assertThat("_$jscoverage['/dir/file.js'].lineData[7]++;\n", equalTo(statement.toSource()));
        assertThat(validLines, hasItem(7));
    }

    @Test(expected = IllegalStateException.class)
    public void shouldThrowExceptionIfLineNumberInvalid() {
View Full Code Here

    @Test
    public void shouldCreateFunctionInstrumentationStatement() {
        ExpressionStatement statement = builder.buildFunctionInstrumentationStatement(7, "/dir/file.js");

        assertThat("_$jscoverage['/dir/file.js'].functionData[7]++;\n", equalTo(statement.toSource()));
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.