Skip to content

IOSerialize and IODeserialize testing wrt. unseen string problem #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tests/Hippopotomonstrosesquippedaliophobia.vos
Binary file not shown.
30 changes: 30 additions & 0 deletions tests/IOUtilsTests.tla
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,35 @@ TXTDeserializeResult == Deserialize(file, [format |-> "TXT", charset |-> "UTF-8"
ASSUME(LET ret == TXTDeserializeResult IN /\ ret.exitValue = 0
/\ ret.stdout = payloadTXT
/\ ret.stderr = "")

---------------------------------------------------------------------------------------------------------------------------

\* Simple round-trip test with a variety of different small structures

file2 == "/tmp/bin-serialize-test.vos"
payloadBIN == <<
"foo",
{"bar"},
42,
1..3,
[x |-> 1, y |-> 2]
>>

ASSUME /\ IOSerialize(payloadBIN, file2, FALSE)
/\ LET value == IODeserialize(file2, FALSE)
IN value = payloadBIN

\* Test: can we read a string TLC has never encountered before?
\* !Danger: writing the string literal at any point in the TLA+ breaks the test!

\* The bug this tests for is that TLC can only read string values that are already interned in its
\* in-memory string table. If the string is so much as in the spec at all, TLC can load it.
\* If the string has was never interned however, then TLC would crash when accessing the value
\* (e.g., printing it), because the string table gives `null` on lookup.
\* The weird long name is chosen to avoid any other tests mentioning this string.
ASSUME LET strValue == IODeserialize("tests/Hippopotomonstrosesquippedaliophobia.vos", FALSE)
IN /\ PrintT(strValue)
\* Intended value (in a comment, so not "seen" by TLC)
\* /\ strValue = "Hippopotomonstrosesquippedaliophobia"

=============================================================================