Esempio n. 1
0
 public void CanParseAllTogether()
 {
     AssertParser.SucceedsWith(
         AssemblerParser.Assembler,
         "  label:  mov   a  ,  b  ;  comment  ",
         lines => Assert.Equal(new AssemblerLine("label", "mov", new[] { "a", "b" }, "  comment  "), lines.Single()));
 }
Esempio n. 2
0
 public void CanParseLabelWithSpaces()
 {
     AssertParser.SucceedsWith(
         AssemblerParser.Assembler,
         "  label :  ",
         lines => Assert.Equal(new AssemblerLine("label", null, null, null), lines.Single()));
 }
Esempio n. 3
0
 public void CanParseIntructionWithSpaces()
 {
     AssertParser.SucceedsWith(
         AssemblerParser.Assembler,
         " mov   a , b ",
         lines => Assert.Equal(new AssemblerLine(null, "mov", new[] { "a", "b" }, null), lines.Single()));
 }
Esempio n. 4
0
 public void CanParseComment()
 {
     AssertParser.SucceedsWith(
         AssemblerParser.Assembler,
         ";comment",
         lines => Assert.Equal(new AssemblerLine(null, null, null, "comment"), lines.Single()));
 }
Esempio n. 5
0
 public void CanParseSeceralLines()
 {
     AssertParser.SucceedsWith(
         AssemblerParser.Assembler,
         @"      ;multiline sample
                 label:  
                 mov   a  ,  b;",
         lines => Assert.Equal(
             new[]
     {
         new AssemblerLine(null, null, null, "multiline sample"),
         new AssemblerLine("label", null, null, null),
         new AssemblerLine(null, "mov", new[] { "a", "b" }, "")
     },
             lines));
 }
Esempio n. 6
0
 public void CanParseEmpty()
 {
     AssertParser.SucceedsWith(AssemblerParser.Assembler, string.Empty, Assert.Empty);
 }
Esempio n. 7
0
 public void ReturningValue_DoesNotAdvanceInput()
 {
     var p = Parse.Return(1);
     AssertParser.SucceedsWith(p, "abc", n => Assert.Equal(1, n));
 }
Esempio n. 8
0
 public void IgnoreCaseParser()
 {
     var ab = Parse.IgnoreCase("ab").Text();
     AssertParser.SucceedsWith(ab, "Ab", m => Assert.Equal("Ab", m));
 }
Esempio n. 9
0
 public void ExceptStopsConsumingInputWhenExclusionParsed()
 {
     var exceptAa = Parse.AnyChar.Except(Parse.String("aa")).Many().Text();
     AssertParser.SucceedsWith(exceptAa, "abcaab", r => Assert.Equal("abc", r));
 }