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

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

            Assert.AreEqual("(function() {\n  alert('test');\n}).call(this);\n", result);
        }
 public override IProcessResult Process(string filePath, string content)
 {
     var compiler = new CoffeeScriptCompiler();
     return new ProcessResult(compiler.Compile(content));
 }
示例#4
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);
 }
 public string Process(string filePath, string content)
 {
     var compiler = new CoffeeScriptCompiler();
     return compiler.Compile(content);
 }