Skip to content

Commit b5aaf1f

Browse files
author
Andy C
committed
[spec/hay] Elaborate on stage 1 and stage 2 evaluation
This seems promising.
1 parent ff6db71 commit b5aaf1f

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

spec/hay.test.sh

+32-17
Original file line numberDiff line numberDiff line change
@@ -821,38 +821,53 @@ echo '
821821
Package cpython {
822822
version = "3.12"
823823
url = "https://python.org/"
824-
if (false) {
825824
proc build {
825+
echo "hi from build proc"
826826
echo $version
827827
}
828828
}
829-
}
830829
' >def.hay
831830

832831
# TODO:
833-
# - nullify_fields=true - well some of them aren't fields
834-
# - nullify=true
835-
# - errors='null'
836-
# - on_error=null
837-
# - drop_with='error' drop_with='null'
838-
# - degrade_to_null=true
839-
# - replace_with_null=true
840-
# - null_replace=true
841-
# - null_replacer=true # replacer can be a function?
842-
# - errors=false # too vague?
843-
#
832+
# null_replacer=true
844833
# JavaScript has a second "replacer" arg, which can be a function, or an array
845834
# I guess you can specify replacer=null
835+
#
836+
# Invert it: Or maybe type_errors=true
837+
#
838+
# When type_errors=false (default), any unserializable value becomes null
839+
840+
echo 'json write (_hay())' > stage-1.ysh
841+
842+
# Stage 1
843+
844+
... $[ENV.SH] -o ysh:all
845+
--eval-pure pre.ysh
846+
--eval-pure def.hay
847+
--eval-pure stage-1.ysh
848+
-c ''
849+
|| true
850+
;
846851

847-
echo 'json write (_hay())' > post.ysh
852+
# Stage 2
853+
854+
echo '
855+
var pkg = _hay().children[0]
856+
var build_proc = pkg.attrs.build
857+
build_proc
858+
' > stage-2.ysh
859+
860+
# Stage 1
848861

849862
... $[ENV.SH] -o ysh:all
850-
--eval pre.ysh
851-
--eval def.hay
852-
--eval post.ysh
863+
--eval-pure pre.ysh
864+
--eval-pure def.hay
865+
--eval stage-2.ysh # This one isn't pure
853866
-c ''
854867
;
855868

869+
870+
856871
## STDOUT:
857872
a
858873
## END

0 commit comments

Comments
 (0)