Files
WoofWare.Expect/WoofWare.Expect.Test/TestSnapshotFinding/TestUnicodeCharacters.fs
2025-07-30 08:06:15 +00:00

457 lines
12 KiB
Forth
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace WoofWare.Expect.Test
open NUnit.Framework
open WoofWare.Expect
[<TestFixture>]
module TestUnicodeCharacters =
[<OneTimeSetUp>]
let ``Prepare to bulk-update tests`` () =
// GlobalBuilderConfig.enterBulkUpdateMode ()
()
[<OneTimeTearDown>]
let ``Update all tests`` () =
GlobalBuilderConfig.updateAllSnapshots ()
type Dummy = class end
[<Test>]
let ``Unicode emoji in string`` () =
let source =
Assembly.getEmbeddedResource typeof<Dummy>.Assembly "UnicodeCharacters.fs"
|> _.Split('\n')
expect {
snapshot
@"namespace BigExample
open WoofWare.Expect
module MyModule =
let emoji () =
expect {
snapshot ""Updated with 🚀🌟✨ more 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""
}
"
return
SnapshotUpdate.updateSnapshotAtLine source 8 "Updated with 🚀🌟✨ more emoji!"
|> String.concat "\n"
}
[<Test>]
let ``Unicode Chinese characters multi-line`` () =
let source =
Assembly.getEmbeddedResource typeof<Dummy>.Assembly "UnicodeCharacters.fs"
|> _.Split('\n')
expect {
snapshot
@"namespace BigExample
open WoofWare.Expect
module MyModule =
let emoji () =
expect {
snapshot @""Hello 👋 World 🌍 with emoji 🎉🎊""
return 123
}
let chineseCharacters () =
expect {
snapshot @""Chinese poem:
静夜思
床前明月光
疑是地上霜
举头望明月
低头思故乡""
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""
}
"
return
SnapshotUpdate.updateSnapshotAtLine source 14 "Chinese poem:\n静夜思\n床前明月光\n疑是地上霜\n举头望明月\n低头思故乡"
|> String.concat "\n"
}
[<Test>]
let ``Arabic RTL`` () =
let source =
Assembly.getEmbeddedResource typeof<Dummy>.Assembly "UnicodeCharacters.fs"
|> _.Split('\n')
expect {
snapshot
@"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 ""Updated Arabic: مرحبا بالعالم""
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""
}
"
return
SnapshotUpdate.updateSnapshotAtLine source 20 "Updated Arabic: مرحبا بالعالم"
|> String.concat "\n"
}
[<Test>]
let ``Combining characters`` () =
let source =
Assembly.getEmbeddedResource typeof<Dummy>.Assembly "UnicodeCharacters.fs"
|> _.Split('\n')
expect {
snapshot
@"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 ""updated test with combining: and ä!""
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""
}
"
return
SnapshotUpdate.updateSnapshotAtLine source 27 "updated test with combining: e\u0301 and a\u0308!"
|> String.concat "\n"
}
[<Test>]
let ``Mixed scripts`` () =
let source =
Assembly.getEmbeddedResource typeof<Dummy>.Assembly "UnicodeCharacters.fs"
|> _.Split('\n')
expect {
snapshot
@"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 ""Updated 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""
}
"
return
SnapshotUpdate.updateSnapshotAtLine source 33 "Updated mixed: English, русский, 日本語, العربية, emoji 🚀"
|> String.concat "\n"
}
[<Test>]
let ``ZWBS character`` () =
let source =
Assembly.getEmbeddedResource typeof<Dummy>.Assembly "UnicodeCharacters.fs"
|> _.Split('\n')
expect {
snapshot
@"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 ""Updated: Zerowidthspacetest"" // Contains U+200B
return ""zwsp""
}
let mathSymbols () =
expect {
snapshot """"""Math: ∀x∈, ∃y: + = 1 |x| 1""""""
return ""math""
}
"
return
SnapshotUpdate.updateSnapshotAtLine source 39 "Updated: Zerowidthspacetest"
|> String.concat "\n"
}
[<Test>]
let ``Maths`` () =
let source =
Assembly.getEmbeddedResource typeof<Dummy>.Assembly "UnicodeCharacters.fs"
|> _.Split('\n')
expect {
snapshot
@"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 ""Pretty vacuous, huh: ∀x∈, ∃y: + = 1 |x| 1""
return ""math""
}
"
return
SnapshotUpdate.updateSnapshotAtLine source 45 "Pretty vacuous, huh: ∀x∈, ∃y: + = 1 |x| 1"
|> String.concat "\n"
}