Example #1
0
        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 EmbeddedCoffeeScriptCompiler();
            compiler.Compile(source);
        }
Example #2
0
        public void CompileWithSimpleAlertSucceeds()
        {
            var compiler = new EmbeddedCoffeeScriptCompiler();

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

            Assert.AreEqual("(function() {\n  alert('test');\n}).call(this);\n", result);
        }
 public string Process(string filePath, string content)
 {
     var compiler = new EmbeddedCoffeeScriptCompiler();
     return compiler.Compile(content);
 }
Example #4
0
 public void CompileFailsGracefullyOnMono()
 {
     var compiler = new EmbeddedCoffeeScriptCompiler();
     var exception = Assert.Throws(typeof(NotSupportedException), () => compiler.Compile(""));
     Assert.AreEqual("Coffeescript not yet supported for mono.", exception.Message);
 }