# Exercise: Writing Files
#
# `file.spit` writes a String to disk, *replacing* whatever was there.
#
# Stack effect: ( content path -- status )
#   content : String — the bytes to write
#   path    : String — destination
#   status  : Bool   — true on success, false if the write failed
#
# Notice the argument order: content goes UNDER path on the stack.
# A common bug is to swap them and end up writing the path string
# itself into a file named after your message.
#
# Sister word: `file.append` has the same shape but appends rather
# than overwriting. You'll use it in 05-combine.
#
# Your task: Write the string "Hello, file!" to
# /tmp/seqlings-write.txt, then slurp it back and return the result
# (chomped) so the assertion can compare it to the original.
#
# Use /tmp/* for output so the repo stays clean. The status Bools
# from spit and slurp can be drained with `drop` here — we trust
# /tmp to be writable and the round-trip to succeed.
#
# When done, delete the marker line below.

# I AM NOT DONE

: write-and-read ( -- String )
    # 1) spit "Hello, file!" to /tmp/seqlings-write.txt
    # 2) slurp it back and chomp the trailing newline (if any)
    ""
;

: test-write ( -- )
    write-and-read
    # Do not edit below this line
    "Hello, file!" string.equal? test.assert
;
