Example #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()));
 }
Example #2
0
 public void CanParseLabelWithSpaces()
 {
     AssertParser.SucceedsWith(
         AssemblerParser.Assembler,
         "  label :  ",
         lines => Assert.Equal(new AssemblerLine("label", null, null, null), lines.Single()));
 }
Example #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()));
 }
Example #4
0
 public void CanParseComment()
 {
     AssertParser.SucceedsWith(
         AssemblerParser.Assembler,
         ";comment",
         lines => Assert.Equal(new AssemblerLine(null, null, null, "comment"), lines.Single()));
 }
Example #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));
 }
Example #6
0
 public void CanParseEmpty()
 {
     AssertParser.SucceedsWith(AssemblerParser.Assembler, string.Empty, Assert.Empty);
 }
Example #7
0
 public void ReturningValue_DoesNotAdvanceInput()
 {
     var p = Parse.Return(1);
     AssertParser.SucceedsWith(p, "abc", n => Assert.Equal(1, n));
 }
Example #8
0
 public void IgnoreCaseParser()
 {
     var ab = Parse.IgnoreCase("ab").Text();
     AssertParser.SucceedsWith(ab, "Ab", m => Assert.Equal("Ab", m));
 }
Example #9
0
 public void ExceptStopsConsumingInputWhenExclusionParsed()
 {
     var exceptAa = Parse.AnyChar.Except(Parse.String("aa")).Many().Text();
     AssertParser.SucceedsWith(exceptAa, "abcaab", r => Assert.Equal("abc", r));
 }