public void CompileWithComplexScriptSucceeds()
        {
            string source = @"# Assignment:
            number   = 42
            opposite = true

            # Conditions:
            number = -42 if opposite

            # Functions:
            square = (x) -> x * x

            # Arrays:
            list = [1, 2, 3, 4, 5]

            # Objects:
            math =
              root:   Math.sqrt
              square: square
              cube:   (x) -> x * square x

            # Splats:
            race = (winner, runners...) ->
              print winner, runners

            # Existence:
            alert 'I knew it!' if elvis?";

            var compiler = new CoffeescriptCompiler();
            string result = compiler.Compile(source);
        }
        public void CompileWithSimpleAlertSucceeds()
        {
            var compiler = new CoffeescriptCompiler();

            string result = compiler.Compile("alert 'test' ");

            Assert.AreEqual("(function() {\n  alert('test');\n}).call(this);\n", result);
        }
예제 #3
0
 public void CompileFailsGracefullyOnMono()
 {
     var compiler = new CoffeescriptCompiler();
     var exception = Assert.Throws(typeof (NotSupportedException), () => compiler.Compile(""));
     Assert.AreEqual("Coffeescript not yet supported for mono.", exception.Message);
 }