예제 #1
0
def test_compile_source():
    compiler = CoffeeScript()

    assert clean_javascript(compiler.compile_source('console.log "Hello, World!"')) == """(function() {\n  console.log("Hello, World!");\n}).call(this);"""

    with pytest.raises(StaticCompilationError):
        compiler.compile_source('console.log "Hello, World!')

    # Test non-ascii
    assert clean_javascript(compiler.compile_source('console.log "Привет, Мир!"')) == """(function() {\n  console.log("Привет, Мир!");\n}).call(this);"""
예제 #2
0
def test_compile_source():
    compiler = CoffeeScript()

    assert (clean_javascript(
        compiler.compile_source('console.log "Hello, World!"')
    ) == """(function() {\n  console.log("Hello, World!");\n}).call(this);""")

    with pytest.raises(StaticCompilationError):
        compiler.compile_source('console.log "Hello, World!')

    # Test non-ascii
    assert (clean_javascript(
        compiler.compile_source('console.log "Привет, Мир!"')
    ) == """(function() {\n  console.log("Привет, Мир!");\n}).call(this);""")
예제 #3
0
    def test_compile_source(self):
        compiler = CoffeeScript()

        self.assertEqual(
            self.clean_javascript(compiler.compile_source('console.log "Hello, World!"')),
            """(function() {\n  console.log("Hello, World!");\n}).call(this);"""
        )

        self.assertRaises(
            StaticCompilationError,
            lambda: compiler.compile_source('console.log "Hello, World!')
        )

        # Test non-ascii
        self.assertEqual(
            self.clean_javascript(compiler.compile_source('console.log "Привет, Мир!"')),
            """(function() {\n  console.log("Привет, Мир!");\n}).call(this);"""
        )
    def test_compile_source(self):
        compiler = CoffeeScript()

        self.assertEqual(
            self.clean_javascript(
                compiler.compile_source('console.log "Hello, World!"')),
            """(function() {\n  console.log("Hello, World!");\n}).call(this);"""
        )

        self.assertRaises(
            StaticCompilationError,
            lambda: compiler.compile_source('console.log "Hello, World!'))

        # Test non-ascii
        self.assertEqual(
            self.clean_javascript(
                compiler.compile_source('console.log "Привет, Мир!"')),
            """(function() {\n  console.log("Привет, Мир!");\n}).call(this);"""
        )