public void PrologTest() { string input = @"@namespace=System.Web.Mvc @namespace=System.Generic @type=List<string> %tag"; var parser = new NHamlParser(input); parser.Parse(); Assert.AreEqual(NHamlParser.UsingDirectives + "using System.Web.Mvc;" + System.Environment.NewLine + "using System.Generic;" + System.Environment.NewLine + NHamlParser.InitialText("List<string>") + NHamlParser.EndText, parser.codeMapper.output); input = @"@type=List<string> %tag"; parser = new NHamlParser(input); parser.Parse(); Assert.AreEqual(NHamlParser.UsingDirectives + NHamlParser.InitialText("List<string>") + NHamlParser.EndText, parser.codeMapper.output); }
public void CodeGenerationTest() { string input = @" - var x = new StringBuilder(""y""); = x %span= x+x"; var parser = new NHamlParser(input); parser.Parse(); Assert.AreEqual(NHamlParser.UsingDirectives + NHamlParser.InitialText(null) + @" var x = new StringBuilder(""y""); { }System.Console.WriteLine( x); System.Console.WriteLine( x+x); " + NHamlParser.EndText, parser.codeMapper.output); }
public void BlockCodeTest() { string input = @" - using (string s in Strings) = s - using (char c in s) = c = c+c = s+s %span= null"; var parser = new NHamlParser(input); parser.Parse(); Assert.AreEqual(NHamlParser.UsingDirectives + NHamlParser.InitialText(null) + @" using (string s in Strings) { System.Console.WriteLine( s); using (char c in s) { System.Console.WriteLine( c); System.Console.WriteLine( c+c); }System.Console.WriteLine( s+s); }System.Console.WriteLine( null); " + NHamlParser.EndText, parser.codeMapper.output); }