-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea55408
commit d808657
Showing
16 changed files
with
864 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
Lox.Compiler.Tests/Integration/Lexing/Patterns/CommaPatternTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Lox.Compiler.Lexing; | ||
using Lox.Compiler.Tests.Common; | ||
|
||
namespace Lox.Compiler.Tests.Integration.Lexing.Patterns | ||
{ | ||
[TestClass] | ||
public sealed class CommaPatternTest | ||
{ | ||
[TestMethod] | ||
public void TestSingle() | ||
{ | ||
var file = string.Empty; | ||
var source = ","; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.COMMA, string.Empty), | ||
new Token(file, 1, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
|
||
[TestMethod] | ||
public void TestSurrounded() | ||
{ | ||
var file = string.Empty; | ||
var source = " , "; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 1, TokenType.COMMA, string.Empty), | ||
new Token(file, 2, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 3, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2), | ||
new SourcePosition(file, 2, 1, 3), | ||
new SourcePosition(file, 3, 1, 4) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
Lox.Compiler.Tests/Integration/Lexing/Patterns/DotPatternTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Lox.Compiler.Lexing; | ||
using Lox.Compiler.Tests.Common; | ||
|
||
namespace Lox.Compiler.Tests.Integration.Lexing.Patterns | ||
{ | ||
[TestClass] | ||
public sealed class DotPatternTest | ||
{ | ||
[TestMethod] | ||
public void TestSingle() | ||
{ | ||
var file = string.Empty; | ||
var source = "."; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.DOT, string.Empty), | ||
new Token(file, 1, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
|
||
[TestMethod] | ||
public void TestSurrounded() | ||
{ | ||
var file = string.Empty; | ||
var source = " . "; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 1, TokenType.DOT, string.Empty), | ||
new Token(file, 2, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 3, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2), | ||
new SourcePosition(file, 2, 1, 3), | ||
new SourcePosition(file, 3, 1, 4) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
Lox.Compiler.Tests/Integration/Lexing/Patterns/LeftArrowPatternTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Lox.Compiler.Lexing; | ||
using Lox.Compiler.Tests.Common; | ||
|
||
namespace Lox.Compiler.Tests.Integration.Lexing.Patterns | ||
{ | ||
[TestClass] | ||
public sealed class LeftArrowPatternTest | ||
{ | ||
[TestMethod] | ||
public void TestSingle() | ||
{ | ||
var file = string.Empty; | ||
var source = "<"; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.LEFT_ARROW, string.Empty), | ||
new Token(file, 1, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
|
||
[TestMethod] | ||
public void TestSurrounded() | ||
{ | ||
var file = string.Empty; | ||
var source = " < "; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 1, TokenType.LEFT_ARROW, string.Empty), | ||
new Token(file, 2, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 3, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2), | ||
new SourcePosition(file, 2, 1, 3), | ||
new SourcePosition(file, 3, 1, 4) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
Lox.Compiler.Tests/Integration/Lexing/Patterns/LeftCirclePatternTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Lox.Compiler.Lexing; | ||
using Lox.Compiler.Tests.Common; | ||
|
||
namespace Lox.Compiler.Tests.Integration.Lexing.Patterns | ||
{ | ||
[TestClass] | ||
public sealed class LeftCirclePatternTest | ||
{ | ||
[TestMethod] | ||
public void TestSingle() | ||
{ | ||
var file = string.Empty; | ||
var source = "("; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.LEFT_CIRCLE, string.Empty), | ||
new Token(file, 1, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
|
||
[TestMethod] | ||
public void TestSurrounded() | ||
{ | ||
var file = string.Empty; | ||
var source = " ( "; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 1, TokenType.LEFT_CIRCLE, string.Empty), | ||
new Token(file, 2, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 3, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2), | ||
new SourcePosition(file, 2, 1, 3), | ||
new SourcePosition(file, 3, 1, 4) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
Lox.Compiler.Tests/Integration/Lexing/Patterns/LeftCurlyPatternTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Lox.Compiler.Lexing; | ||
using Lox.Compiler.Tests.Common; | ||
|
||
namespace Lox.Compiler.Tests.Integration.Lexing.Patterns | ||
{ | ||
[TestClass] | ||
public sealed class LeftCurlyePatternTest | ||
{ | ||
[TestMethod] | ||
public void TestSingle() | ||
{ | ||
var file = string.Empty; | ||
var source = "{"; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.LEFT_CURLY, string.Empty), | ||
new Token(file, 1, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
|
||
[TestMethod] | ||
public void TestSurrounded() | ||
{ | ||
var file = string.Empty; | ||
var source = " { "; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 1, TokenType.LEFT_CURLY, string.Empty), | ||
new Token(file, 2, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 3, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2), | ||
new SourcePosition(file, 2, 1, 3), | ||
new SourcePosition(file, 3, 1, 4) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
Lox.Compiler.Tests/Integration/Lexing/Patterns/MinusPatternTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Lox.Compiler.Lexing; | ||
using Lox.Compiler.Tests.Common; | ||
|
||
namespace Lox.Compiler.Tests.Integration.Lexing.Patterns | ||
{ | ||
[TestClass] | ||
public sealed class MinusPatternTest | ||
{ | ||
[TestMethod] | ||
public void TestSingle() | ||
{ | ||
var file = string.Empty; | ||
var source = "-"; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.MINUS, string.Empty), | ||
new Token(file, 1, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
|
||
[TestMethod] | ||
public void TestSurrounded() | ||
{ | ||
var file = string.Empty; | ||
var source = " - "; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 1, TokenType.MINUS, string.Empty), | ||
new Token(file, 2, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 3, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2), | ||
new SourcePosition(file, 2, 1, 3), | ||
new SourcePosition(file, 3, 1, 4) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
Lox.Compiler.Tests/Integration/Lexing/Patterns/NotPatternTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Lox.Compiler.Lexing; | ||
using Lox.Compiler.Tests.Common; | ||
|
||
namespace Lox.Compiler.Tests.Integration.Lexing.Patterns | ||
{ | ||
[TestClass] | ||
public sealed class NotPatternTest | ||
{ | ||
[TestMethod] | ||
public void TestSingle() | ||
{ | ||
var file = string.Empty; | ||
var source = "!"; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.NOT, string.Empty), | ||
new Token(file, 1, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
|
||
[TestMethod] | ||
public void TestSurrounded() | ||
{ | ||
var file = string.Empty; | ||
var source = " ! "; | ||
|
||
var truthTokens = new Token[] | ||
{ | ||
new Token(file, 0, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 1, TokenType.NOT, string.Empty), | ||
new Token(file, 2, TokenType.WHITESPACE, string.Empty), | ||
new Token(file, 3, TokenType.END_OF_FILE, string.Empty) | ||
}; | ||
var truthSourcemap = new SourcePosition[] | ||
{ | ||
new SourcePosition(file, 0, 1, 1), | ||
new SourcePosition(file, 1, 1, 2), | ||
new SourcePosition(file, 2, 1, 3), | ||
new SourcePosition(file, 3, 1, 4) | ||
}; | ||
|
||
LexingTestHelper.AssertScanner(source, truthTokens, truthSourcemap); | ||
} | ||
} | ||
} |
Oops, something went wrong.