-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[stdlib] Skeleton for stdlib/{args,testing}.sh
- args: Args definition, and parseArgs() - testing: describe and assert This brought up a whole bunch of issues
- Loading branch information
Andy C
committed
Aug 27, 2023
1 parent
e9a1acf
commit 09b13a4
Showing
4 changed files
with
99 additions
and
23 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
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
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,39 @@ | ||
# args.ysh | ||
# | ||
# Usage: | ||
# source --builtin args.sh | ||
# | ||
# Args :spec { | ||
# flag -v --verbose "Verbosely" # default is Bool, false | ||
# flag -P --max-procs ( | ||
# Int, default=-1, | ||
# desc="Run at most P processes at a time" | ||
# ) | ||
# arg src (desc="Source") | ||
# arg src (desc="Dest") | ||
# } | ||
# | ||
# var arg, i = parseArgs(spec, ARGV) | ||
# | ||
# echo "Verbose $[arg.verbose]" | ||
# | ||
|
||
proc Args(spec Ref ; ; block) { | ||
# TODO: evaluate block somehow | ||
# | ||
# eval ( ) function does it I guess? | ||
# | ||
# You have to put 'flag' and 'arg' in scope | ||
|
||
echo hi | ||
|
||
#= spec | ||
#= block | ||
} | ||
|
||
func parseArgs(spec, argv) { | ||
var i = 0 | ||
var arg = {} | ||
|
||
return ([arg, i]) | ||
} |
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,22 @@ | ||
# testing.ysh | ||
# | ||
# Usage: | ||
# source --builtin testing.sh | ||
# | ||
# func f(x) { return (x + 1) } | ||
# | ||
# describe foo { | ||
# assert (43 === f(42)) | ||
# } | ||
|
||
proc describe (...desc, ) { | ||
echo hi | ||
} | ||
|
||
# is 'cond Expr' lazily evaluated? | ||
# Or all proc arguments are autoomatically lazy, except words? | ||
|
||
proc assert (; cond ) { | ||
echo hi | ||
} | ||
|