Added testing ability
For the full details, see patches/README.md :-)
This commit is contained in:
parent
95c8ea3cb3
commit
6ccd55729e
49 changed files with 160 additions and 9 deletions
4
patches/01_hello.patch
Normal file
4
patches/01_hello.patch
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
19c19
|
||||
< fn main() void {
|
||||
---
|
||||
> pub fn main() void {
|
||||
4
patches/02_std.patch
Normal file
4
patches/02_std.patch
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
14c14
|
||||
< ??? = @import("std");
|
||||
---
|
||||
> const std = @import("std");
|
||||
1
patches/03_assignment.patch
Normal file
1
patches/03_assignment.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/04_arrays.patch
Normal file
1
patches/04_arrays.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/05_arrays2.patch
Normal file
1
patches/05_arrays2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/06_strings.patch
Normal file
1
patches/06_strings.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/07_strings2.patch
Normal file
1
patches/07_strings2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/08_quiz.patch
Normal file
1
patches/08_quiz.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/09_if.patch
Normal file
1
patches/09_if.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/10_if2.patch
Normal file
1
patches/10_if2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/11_while.patch
Normal file
1
patches/11_while.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/12_while2.patch
Normal file
1
patches/12_while2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/13_while3.patch
Normal file
1
patches/13_while3.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/14_while4.patch
Normal file
1
patches/14_while4.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/15_for.patch
Normal file
1
patches/15_for.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/16_for2.patch
Normal file
1
patches/16_for2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/17_quiz2.patch
Normal file
1
patches/17_quiz2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/18_functions.patch
Normal file
1
patches/18_functions.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/19_functions2.patch
Normal file
1
patches/19_functions2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/20_quiz3.patch
Normal file
1
patches/20_quiz3.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/21_errors.patch
Normal file
1
patches/21_errors.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/22_errors2.patch
Normal file
1
patches/22_errors2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/23_errors3.patch
Normal file
1
patches/23_errors3.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/24_errors4.patch
Normal file
1
patches/24_errors4.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/25_errors5.patch
Normal file
1
patches/25_errors5.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/26_hello2.patch
Normal file
1
patches/26_hello2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/27_defer.patch
Normal file
1
patches/27_defer.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/28_defer2.patch
Normal file
1
patches/28_defer2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/29_errdefer.patch
Normal file
1
patches/29_errdefer.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/30_switch.patch
Normal file
1
patches/30_switch.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/31_switch2.patch
Normal file
1
patches/31_switch2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/32_unreachable.patch
Normal file
1
patches/32_unreachable.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/33_iferror.patch
Normal file
1
patches/33_iferror.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/34_quiz4.patch
Normal file
1
patches/34_quiz4.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/35_enums.patch
Normal file
1
patches/35_enums.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/36_enums2.patch
Normal file
1
patches/36_enums2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/37_structs.patch
Normal file
1
patches/37_structs.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/38_structs2.patch
Normal file
1
patches/38_structs2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/39_pointers.patch
Normal file
1
patches/39_pointers.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/40_pointers2.patch
Normal file
1
patches/40_pointers2.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/41_pointers3.patch
Normal file
1
patches/41_pointers3.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/42_pointers4.patch
Normal file
1
patches/42_pointers4.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/43_pointers5.patch
Normal file
1
patches/43_pointers5.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
patches/44_quiz5.patch
Normal file
1
patches/44_quiz5.patch
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -1,9 +1,35 @@
|
|||
# The ziglings/patches Directory
|
||||
# No Peeking! :-)
|
||||
|
||||
This is how ziglings is tested.
|
||||
Welcome to the ziglings/patches directory. This is how ziglings is tested.
|
||||
|
||||
The patches fix the broken exercises so that they work again.
|
||||
The patches fix the broken exercises so that they work again, which means the
|
||||
answers are here, so no peeking!
|
||||
|
||||
No peeking! :-)
|
||||
## Éowyn
|
||||
|
||||
A Bash shell script named `eowyn.sh` dwells here. She heals the little broken
|
||||
programs and places them in a `healed` directory, which is not committed to the
|
||||
repo.
|
||||
|
||||
```bash
|
||||
$ ./eowyn.sh
|
||||
```
|
||||
|
||||
(If you invoke her from elsewhere, she'll come here to ply her trade.)
|
||||
|
||||
The `build.zig` build script at the heart of Ziglings has a top-secret option
|
||||
which tells it to test from the `patches/healed/` dir rather than `exercises/`:
|
||||
|
||||
```bash
|
||||
$ zig build -Dhealed [step]
|
||||
```
|
||||
|
||||
Éowyn tests all healed programs using this secret option.
|
||||
|
||||
|
||||
## Gollum
|
||||
|
||||
Another Bash shell script named `gollum.sh` may also be found. He snatches the
|
||||
original answers and stows them in his secret answers stash. If you leave him
|
||||
alone, he'll leave you alone.
|
||||
|
||||
(Further tooling and explanation goes here.)
|
||||
|
|
|
|||
45
patches/eowyn.sh
Executable file
45
patches/eowyn.sh
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# "I will be a shieldmaiden no longer,
|
||||
# nor vie with the great Riders, nor
|
||||
# take joy only in the songs of slaying.
|
||||
# I will be a healer, and love all things
|
||||
# that grow and are not barren."
|
||||
# Éowyn, The Return of the King
|
||||
#
|
||||
#
|
||||
# This script shall heal the little broken programs
|
||||
# using the patches in this directory and convey them
|
||||
# to convalesce in the healed directory.
|
||||
#
|
||||
|
||||
# We run from the patches dir. Go there now if not already.
|
||||
cd $(dirname $(which $0))
|
||||
pwd # Show it upon the screen so all shall be made apparent.
|
||||
|
||||
# Create healed/ directory here if it doesn't already exist.
|
||||
mkdir -p healed
|
||||
|
||||
# Cycle through all the little broken Zig applications.
|
||||
for broken in ../exercises/*.zig
|
||||
do
|
||||
# Remove the dir and extension, rendering the True Name.
|
||||
true_name=$(basename $broken .zig)
|
||||
|
||||
if [[ -f $true_name.patch ]]
|
||||
then
|
||||
# Apply the bandages to the wounds, grow new limbs, let
|
||||
# new life spring into the broken bodies of the fallen.
|
||||
echo Healing $true_name...
|
||||
patch --output=healed/$true_name.zig $broken $true_name.patch
|
||||
else
|
||||
echo Cannot heal $true_name. Making empty patch.
|
||||
echo > $true_name.patch
|
||||
fi
|
||||
done
|
||||
|
||||
# Return to the home of our ancestors.
|
||||
cd ..
|
||||
|
||||
# Test the healed exercises. May the compiler have mercy upon us.
|
||||
zig build -Dhealed
|
||||
24
patches/gollum.sh
Executable file
24
patches/gollum.sh
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# "It isn't fair, my precious, is it,
|
||||
# to ask us what it's got in it's
|
||||
# nassty little pocketsess?"
|
||||
# Gollum, The Hobbit, or There and Back Again
|
||||
#
|
||||
|
||||
cd $(dirname $(which $0))
|
||||
f=$(basename ../exercises/$1*.zig .zig 2> /dev/null)
|
||||
b=../exercises/$f.zig
|
||||
a=../answers/$f.zig
|
||||
p=$f.patch
|
||||
|
||||
printf "\tf: '$f'\n\tb: '$b'\n\ta: '$a'\n"
|
||||
|
||||
if [[ ! -f $b ]]; then echo "We hates it!"; exit 1; fi
|
||||
if [[ ! -a $a ]]; then echo "Where is it? Where is the answer, precious?"; exit; fi
|
||||
|
||||
echo Hisssss!
|
||||
|
||||
diff $b $a > $p
|
||||
|
||||
cat $p
|
||||
Loading…
Add table
Add a link
Reference in a new issue