I/O
- Read stdin
- Read a file
- Print a string
- Print a string with end argument
- Print multiple strings
- Print a number
- Print a nil
- Print multiple arguments of different types
- Print a string to stderr
- Print a string to a file
- Print with a wrong file argument
Read stdin
Given a file named “main.cloe” with:
(print (read) . end "")
And a file named “test.txt” with:
foo
bar
baz
When I run the following commands:
cloe main.cloe < test.txt
Then the stdout should contain exactly:
foo
bar
baz
Read a file
Given a file named “main.cloe” with:
(print (read . file "test.txt") . end "")
And a file named “test.txt” with:
foo
bar
baz
When I successfully run cloe main.cloe
Then the stdout should contain exactly:
foo
bar
baz
Print a string
Given a file named “main.cloe” with:
(print "Hello!")
When I successfully run cloe main.cloe
Then the stdout should contain exactly “Hello!”.
Print a string with end argument
Given a file named “main.cloe” with:
(print "Hello!" . end "!!")
When I successfully run cloe main.cloe
Then the stdout should contain exactly “Hello!!!”.
Print multiple strings
Given a file named “main.cloe” with:
(print "Hello," "world!")
When I successfully run cloe main.cloe
Then the stdout should contain exactly “Hello, world!”.
Print a number
Given a file named “main.cloe” with:
(print 42)
When I successfully run cloe main.cloe
Then the stdout should contain exactly “42”.
Print a nil
Given a file named “main.cloe” with:
(print nil)
When I successfully run cloe main.cloe
Then the stdout should contain exactly “nil”.
Print multiple arguments of different types
Given a file named “main.cloe” with:
(print "string" 42 nil true)
When I successfully run cloe main.cloe
Then the stdout should contain exactly “string 42 nil true”.
Print a string to stderr
Given a file named “main.cloe” with:
(print "This is stderr." . file 2)
When I successfully run cloe main.cloe
Then the stdout should contain exactly “”
And the stderr should contain exactly “This is stderr.”.
Print a string to a file
Given a file named “main.cloe” with:
(print "This is content." . file "output.txt")
When I successfully run cloe main.cloe
Then the stdout should contain exactly “”
And the file “output.txt” should contain exactly:
This is content.
Print with a wrong file argument
Given a file named “main.cloe” with:
(print 42 . file nil)
When I run cloe main.cloe
Then the exit status should not be 0
And the stdout should contain exactly “”
And the stderr should contain “Error”.