Add a whole lot more tests for the parser (#11)

This commit is contained in:
Patrick Stevens
2025-06-16 22:44:42 +01:00
committed by GitHub
parent d115185525
commit 457d7b16de
13 changed files with 2517 additions and 2 deletions

View 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
}

View 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"
}

View 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"
}

View 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"
}

View 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: + = 1 |x| 1"""
return "math"
}