-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added READMEs for examples 5, 6, 7, and 8.
- Loading branch information
しずえ
committed
Oct 28, 2021
1 parent
dfa7e09
commit 0faa71e
Showing
8 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## Example 5. Endless loop | ||
|
||
This example demonstrates how `scold` handles time limits. | ||
|
||
`main.cpp` reads an integer and hangs forever. | ||
|
||
Run the example like so: | ||
``` | ||
$ g++ main.cpp -o loop | ||
$ scold loop | ||
``` | ||
|
||
The output will look like this: | ||
|
||
![scold's output for example 5](output.png) | ||
|
||
Things to note: | ||
1. The tests are sorted by the time they finished and not by their ids. | ||
2. The run-time of the tests is not equal to the time limit, because it includes the time OS needed to terminate the applications. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## Example 6. Application arguments | ||
|
||
This example demonstrates how `scold` allows you to pass command-line arguments to the programs under testing. | ||
|
||
`main.cpp` reads an integer and prints the sum of this integer with an integer passed as a command-line argument. If none were provided, it crashes. | ||
|
||
Run the example like so: | ||
``` | ||
$ g++ main.cpp -o args | ||
$ scold args | ||
``` | ||
|
||
The outputs for (a) no arguments, (b) argument `1`, and (c) argument `0` will look like this | ||
|
||
![scold's output for example 6](output.png) | ||
|
||
Things to note: | ||
1. Because of this feature, you need to be careful, since the flags designated to `scold` should appear *before* the name of the executable. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## Example 7. Testing Node.js apps | ||
|
||
This example demonstrates how `scold` allows you to test programs that cannot be compiled. | ||
|
||
`index.js` parses a line it reads from the `stdin` containing two integers and prints their sum. | ||
|
||
`inputs.txt` describes a number of tests to check that summation works. | ||
|
||
Run the example like so: | ||
``` | ||
$ scold node index | ||
``` | ||
|
||
The output will be | ||
|
||
![scold's output for example 7](output.png) | ||
|
||
Things to note: | ||
1. This is applicable to *any* interpreted languages and even other command-line tools. You can in the very same fashion test application written in go, python, ruby and more. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## Example 7. Input robustness | ||
|
||
This example demonstrates how `scold` checks that the provided `inputs.txt` is correct. | ||
|
||
Run the example like so (note that `.` is an incorrect executable name, but validation of `inputs.txt` will be performed sooner): | ||
``` | ||
$ scold -i inputs1.txt . | ||
``` | ||
|
||
The output will be | ||
|
||
![scold's output for example 8](output.png) | ||
|
||
Things to note: | ||
1. The error messages display the line number and the line that contains the error. | ||
2. The error messages reference the filename and the line of the problematic region (the `.\inputs1.txt:1:` string). | ||
3. The error messages are capable of printing multi-line code snippets. | ||
4. Errors are hierachical: the core error message (that goes after the last `:`) is amended with additional contextual information during the validation stage. It is in essence a Go way of reporting errors. This makes for a clean architecture inside the `scold`'s codebase, and also clearer error messages. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.