mirror of
https://github.com/Smaug123/WoofWare.Expect
synced 2025-10-11 06:58:44 +00:00
Add a whole lot more tests for the parser (#11)
This commit is contained in:
44
WoofWare.Expect.Test/SyntaxCases/CommentsAndSpacing.fs
Normal file
44
WoofWare.Expect.Test/SyntaxCases/CommentsAndSpacing.fs
Normal file
@@ -0,0 +1,44 @@
|
||||
namespace BigExample
|
||||
|
||||
open WoofWare.Expect
|
||||
|
||||
module MyModule =
|
||||
let multipleComments () =
|
||||
expect {
|
||||
snapshot (* first comment *) (* second comment *)
|
||||
(* third comment on new line *)
|
||||
@"test with many comments"
|
||||
|
||||
return 123
|
||||
}
|
||||
|
||||
let nestedComments () =
|
||||
expect {
|
||||
snapshot (* outer (* inner *) comment *) """nested comment test"""
|
||||
return "nested"
|
||||
}
|
||||
|
||||
let commentWithSpecialChars () =
|
||||
expect {
|
||||
snapshot (* comment with "quotes" and \ backslash *) "regular string"
|
||||
return "special"
|
||||
}
|
||||
|
||||
let lotsOfWhitespace () =
|
||||
expect {
|
||||
snapshot
|
||||
|
||||
|
||||
"string after whitespace"
|
||||
|
||||
return "whitespace"
|
||||
}
|
||||
|
||||
let mixedWhitespaceAndComments () =
|
||||
expect {
|
||||
snapshotJson (* comment 1 *)
|
||||
(* comment 2 *)
|
||||
(* comment 3 *) @"123"
|
||||
|
||||
return 123
|
||||
}
|
69
WoofWare.Expect.Test/SyntaxCases/EdgeCases.fs
Normal file
69
WoofWare.Expect.Test/SyntaxCases/EdgeCases.fs
Normal file
@@ -0,0 +1,69 @@
|
||||
namespace BigExample
|
||||
|
||||
open WoofWare.Expect
|
||||
|
||||
module MyModule =
|
||||
let emptyString () =
|
||||
expect {
|
||||
snapshot ""
|
||||
return ""
|
||||
}
|
||||
|
||||
let emptyVerbatim () =
|
||||
expect {
|
||||
snapshot @""
|
||||
return ""
|
||||
}
|
||||
|
||||
let emptyTripleQuote () =
|
||||
expect {
|
||||
snapshot """"""
|
||||
return ""
|
||||
}
|
||||
|
||||
let onlyWhitespace () =
|
||||
expect {
|
||||
snapshot " \t\n "
|
||||
return "whitespace"
|
||||
}
|
||||
|
||||
let quotesInQuotes () =
|
||||
expect {
|
||||
snapshot @"He said ""Hello"" and she said ""Hi"""
|
||||
return "quotes"
|
||||
}
|
||||
|
||||
let backslashesGalore () =
|
||||
expect {
|
||||
snapshot @"C:\Users\Test\Documents\file.txt"
|
||||
return "path"
|
||||
}
|
||||
|
||||
let veryLongLine () =
|
||||
expect {
|
||||
snapshot
|
||||
@"This is a very long line that goes on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and contains over 300 characters to test how the parser handles very long single-line strings"
|
||||
|
||||
return "long line"
|
||||
}
|
||||
|
||||
let leadingNewlines () =
|
||||
expect {
|
||||
snapshot
|
||||
"""
|
||||
|
||||
Starts with newlines"""
|
||||
|
||||
return "leading"
|
||||
}
|
||||
|
||||
let trailingNewlines () =
|
||||
expect {
|
||||
snapshot
|
||||
"""Ends with newlines
|
||||
|
||||
|
||||
"""
|
||||
|
||||
return "trailing"
|
||||
}
|
84
WoofWare.Expect.Test/SyntaxCases/MultilineComplex.fs
Normal file
84
WoofWare.Expect.Test/SyntaxCases/MultilineComplex.fs
Normal file
@@ -0,0 +1,84 @@
|
||||
namespace BigExample
|
||||
|
||||
open WoofWare.Expect
|
||||
|
||||
module MyModule =
|
||||
let veryLongMultiline () =
|
||||
expect {
|
||||
snapshot
|
||||
"""Line 1
|
||||
Line 2
|
||||
Line 3
|
||||
Line 4
|
||||
Line 5
|
||||
Line 6
|
||||
Line 7
|
||||
Line 8
|
||||
Line 9
|
||||
Line 10
|
||||
Indented line 11
|
||||
More indented line 12
|
||||
Line 13
|
||||
Line 14
|
||||
Line 15"""
|
||||
|
||||
return "long"
|
||||
}
|
||||
|
||||
let multilineWithEmptyLines () =
|
||||
expect {
|
||||
snapshot
|
||||
@"First line
|
||||
|
||||
Third line
|
||||
|
||||
|
||||
Sixth line"
|
||||
|
||||
return "empty lines"
|
||||
}
|
||||
|
||||
let multilineWithSpecialChars () =
|
||||
expect {
|
||||
snapshot
|
||||
"""Special chars:
|
||||
Tab: here
|
||||
Quotes: "double" and 'single'
|
||||
Backslash: \ and \\
|
||||
Unicode: 🎯
|
||||
Regex: .*+?[]"""
|
||||
|
||||
return "special"
|
||||
}
|
||||
|
||||
let multilineJson () =
|
||||
expect {
|
||||
snapshotJson
|
||||
@"{
|
||||
""name"": ""test"",
|
||||
""values"": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
],
|
||||
""nested"": {
|
||||
""deep"": true
|
||||
}
|
||||
}"
|
||||
|
||||
return
|
||||
{
|
||||
name = "test"
|
||||
values = [ 1 ; 2 ; 3 ]
|
||||
nested =
|
||||
{|
|
||||
deep = true
|
||||
|}
|
||||
}
|
||||
}
|
||||
|
||||
let windowsLineEndings () =
|
||||
expect {
|
||||
snapshot "Line 1\r\nLine 2\r\nLine 3"
|
||||
return "crlf"
|
||||
}
|
28
WoofWare.Expect.Test/SyntaxCases/RegexMetacharacters.fs
Normal file
28
WoofWare.Expect.Test/SyntaxCases/RegexMetacharacters.fs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace BigExample
|
||||
|
||||
open WoofWare.Expect
|
||||
|
||||
module MyModule =
|
||||
let regexChars () =
|
||||
expect {
|
||||
snapshot @"test with regex chars: .*+?[]{}()|^$\ and more"
|
||||
return 123
|
||||
}
|
||||
|
||||
let regexInTripleQuote () =
|
||||
expect {
|
||||
snapshot """regex: .*+?[]{}()|^$\ in triple quotes"""
|
||||
return 456
|
||||
}
|
||||
|
||||
let regexInRegularString () =
|
||||
expect {
|
||||
snapshot "escaped regex: \\.\\*\\+\\?\\[\\]\\{\\}\\(\\)\\|\\^\\$\\\\"
|
||||
return 789
|
||||
}
|
||||
|
||||
let complexRegexPattern () =
|
||||
expect {
|
||||
snapshotJson @"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
|
||||
return "IP regex"
|
||||
}
|
47
WoofWare.Expect.Test/SyntaxCases/UnicodeCharacters.fs
Normal file
47
WoofWare.Expect.Test/SyntaxCases/UnicodeCharacters.fs
Normal file
@@ -0,0 +1,47 @@
|
||||
namespace BigExample
|
||||
|
||||
open WoofWare.Expect
|
||||
|
||||
module MyModule =
|
||||
let emoji () =
|
||||
expect {
|
||||
snapshot @"Hello 👋 World 🌍 with emoji 🎉🎊"
|
||||
return 123
|
||||
}
|
||||
|
||||
let chineseCharacters () =
|
||||
expect {
|
||||
snapshot """Chinese: 你好世界"""
|
||||
return "hello"
|
||||
}
|
||||
|
||||
let arabicRTL () =
|
||||
expect {
|
||||
snapshot @"Arabic RTL: مرحبا بالعالم"
|
||||
return "rtl test"
|
||||
}
|
||||
|
||||
let combiningCharacters () =
|
||||
expect {
|
||||
// Combining diacritics: e + ́ = é
|
||||
snapshot "test with combining: e\u0301 and a\u0308"
|
||||
return "combining"
|
||||
}
|
||||
|
||||
let mixedScripts () =
|
||||
expect {
|
||||
snapshotJson @"Mixed: English, русский, 日本語, العربية, emoji 🚀"
|
||||
return [ "multilingual" ]
|
||||
}
|
||||
|
||||
let zeroWidthChars () =
|
||||
expect {
|
||||
snapshot @"Zerowidthspacetest" // Contains U+200B
|
||||
return "zwsp"
|
||||
}
|
||||
|
||||
let mathSymbols () =
|
||||
expect {
|
||||
snapshot """Math: ∀x∈ℝ, ∃y: x² + y² = 1 ⟹ |x| ≤ 1"""
|
||||
return "math"
|
||||
}
|
Reference in New Issue
Block a user