Update reactor tests to use (deep) `bind-vals`.
Chris Pressey
4 years ago
822 | 822 | |
823 | 823 | | (reactor (line-terminal) 0 |
824 | 824 | | (macro (args env) |
825 | | (bind-vals (event state) args | |
826 | | (bind event-type (head event) | |
827 | | (if (equal? event-type (literal init)) | |
828 | | (list 0 | |
829 | | (list (literal writeln) (literal ''Hello, world!'')) | |
830 | | (list (literal stop) 0)) | |
831 | | (list 0)))))) | |
825 | | (bind-vals ((event-type event-payload) state) args | |
826 | | (if (equal? event-type (literal init)) | |
827 | | (list state | |
828 | | (list (literal writeln) (literal ''Hello, world!'')) | |
829 | | (list (literal stop) 0)) | |
830 | | (list state))))) | |
832 | 831 | = Hello, world! |
833 | 832 | |
834 | 833 | Reactors which interact with `line-terminal` receive `readln` events. |
842 | 841 | |
843 | 842 | | (reactor (line-terminal) 0 |
844 | 843 | | (macro (args env) |
845 | | (bind-vals (event state) args | |
846 | | (bind event-type (head event) | |
847 | | (bind event-payload (head (tail event)) | |
848 | | (if (equal? event-type (literal readln)) | |
849 | | (list 0 | |
850 | | (list (literal writeln) event-payload)) | |
851 | | (list 0))))))) | |
844 | | (bind-vals ((event-type event-payload) state) args | |
845 | | (if (equal? event-type (literal readln)) | |
846 | | (list state | |
847 | | (list (literal writeln) event-payload)) | |
848 | | (list state))))) | |
852 | 849 | + Cat |
853 | 850 | + Dog |
854 | 851 | = Cat |
877 | 874 | |
878 | 875 | | (reactor (line-terminal) 0 |
879 | 876 | | (macro (args env) |
880 | | (bind-vals (event state) args | |
881 | | (bind event-type (head event) | |
882 | | (bind event-payload (head (tail event)) | |
883 | | (if (equal? event-type (literal readln)) | |
884 | | (list 0 | |
885 | | (list (literal writeln) (literal ''Line:'')) | |
886 | | (list (literal writeln) event-payload)) | |
887 | | (list 0))))))) | |
877 | | (bind-vals ((event-type event-payload) state) args | |
878 | | (if (equal? event-type (literal readln)) | |
879 | | (list state | |
880 | | (list (literal writeln) (literal ''Line:'')) | |
881 | | (list (literal writeln) event-payload)) | |
882 | | (list state))))) | |
888 | 883 | + Cat |
889 | 884 | + Dog |
890 | 885 | = Line: |
897 | 892 | |
898 | 893 | | (reactor (line-terminal) 0 |
899 | 894 | | (macro (args env) |
900 | | (bind-vals (event state) args | |
901 | | (bind event-type (head event) | |
902 | | (bind event-payload (head (tail event)) | |
903 | | (if (equal? event-type (literal readln)) | |
904 | | (list 0 | |
905 | | (literal what-is-this) | |
906 | | (literal i-dont-even) | |
907 | | (list (literal writeln) event-payload)) | |
908 | | (list 0))))))) | |
895 | | (bind-vals ((event-type event-payload) state) args | |
896 | | (if (equal? event-type (literal readln)) | |
897 | | (list state | |
898 | | (literal what-is-this) | |
899 | | (literal i-dont-even) | |
900 | | (list (literal writeln) event-payload)) | |
901 | | (list state))))) | |
909 | 902 | + Cat |
910 | 903 | + Dog |
911 | 904 | = Cat |
921 | 914 | |
922 | 915 | | (reactor (line-terminal) 0 |
923 | 916 | | (macro (args env) |
924 | | (bind-vals (event state) args | |
925 | | (bind event-type (head event) | |
926 | | (bind event-payload (head (tail event)) | |
927 | | (if (equal? event-type (literal readln)) | |
928 | | (if (equal? (head event-payload) 65) | |
929 | | (abort 999999) | |
930 | | (list 0 (list (literal writeln) event-payload))) | |
931 | | (list 0))))))) | |
917 | | (bind-vals ((event-type event-payload) state) args | |
918 | | (if (equal? event-type (literal readln)) | |
919 | | (if (equal? (head event-payload) 65) | |
920 | | (abort 999999) | |
921 | | (list state (list (literal writeln) event-payload))) | |
922 | | (list state))))) | |
932 | 923 | + Cat |
933 | 924 | + Dog |
934 | 925 | + Alligator |
943 | 934 | | (subtract (eval env (head args)) (subtract 0 1)))) |
944 | 935 | | (reactor (line-terminal) 65 |
945 | 936 | | (macro (args env) |
946 | | (bind-vals (event state) args | |
947 | | (bind event-type (head event) | |
948 | | (bind event-payload (head (tail event)) | |
949 | | (if (equal? event-type (literal readln)) | |
950 | | (list (inc state) (list (literal writeln) (list state))) | |
951 | | (list state))))))) | |
937 | | (bind-vals ((event-type event-payload) state) args | |
938 | | (if (equal? event-type (literal readln)) | |
939 | | (list (inc state) (list (literal writeln) (list state))) | |
940 | | (list state))))) | |
952 | 941 | + Cat |
953 | 942 | + Dog |
954 | 943 | + Giraffe |
963 | 952 | | (subtract (eval env (head args)) (subtract 0 1)))) |
964 | 953 | | (reactor (line-terminal) 65 |
965 | 954 | | (macro (args env) |
966 | | (bind-vals (event state) args | |
967 | | (bind event-type (head event) | |
968 | | (bind event-payload (head (tail event)) | |
969 | | (if (equal? event-type (literal readln)) | |
970 | | (list (inc state) (list (literal writeln) (list state))) | |
971 | | (list state))))))) | |
955 | | (bind-vals ((event-type event-payload) state) args | |
956 | | (if (equal? event-type (literal readln)) | |
957 | | (list (inc state) (list (literal writeln) (list state))) | |
958 | | (list state))))) | |
972 | 959 | | (reactor (line-terminal) 0 |
973 | 960 | | (macro (args env) |
974 | | (bind-vals (event state) args | |
975 | | (bind event-type (head event) | |
976 | | (bind event-payload (head (tail event)) | |
977 | | (if (equal? event-type (literal readln)) | |
978 | | (list 0 | |
979 | | (list (literal writeln) event-payload)) | |
980 | | (list 0))))))) | |
961 | | (bind-vals ((event-type event-payload) state) args | |
962 | | (if (equal? event-type (literal readln)) | |
963 | | (list state | |
964 | | (list (literal writeln) event-payload)) | |
965 | | (list state))))) | |
981 | 966 | + Cat |
982 | 967 | + Dog |
983 | 968 | + Giraffe |
994 | 979 | | (subtract (eval env (head args)) (subtract 0 1)))) |
995 | 980 | | (reactor (line-terminal) 65 |
996 | 981 | | (macro (args env) |
997 | | (bind-vals (event state) args | |
998 | | (bind event-type (head event) | |
999 | | (bind event-payload (head (tail event)) | |
1000 | | (if (equal? event-type (literal readln)) | |
1001 | | (if (equal? state 68) | |
1002 | | (list state (list (literal stop) 0)) | |
1003 | | (list (inc state) (list (literal writeln) event-payload))) | |
1004 | | (list state))))))) | |
982 | | (bind-vals ((event-type event-payload) state) args | |
983 | | (if (equal? event-type (literal readln)) | |
984 | | (if (equal? state 68) | |
985 | | (list state (list (literal stop) 0)) | |
986 | | (list (inc state) (list (literal writeln) event-payload))) | |
987 | | (list state))))) | |
1005 | 988 | + Cat |
1006 | 989 | + Dog |
1007 | 990 | + Giraffe |
1017 | 1000 | | (subtract (eval env (head args)) (subtract 0 1)))) |
1018 | 1001 | | (reactor (line-terminal) 65 |
1019 | 1002 | | (macro (args env) |
1020 | | (bind-vals (event state) args | |
1021 | | (bind event-type (head event) | |
1022 | | (bind event-payload (head (tail event)) | |
1023 | | (if (equal? event-type (literal readln)) | |
1024 | | (if (equal? state 68) | |
1025 | | (list state (list (literal stop) 0)) | |
1026 | | (list (inc state) (list (literal writeln) event-payload))) | |
1027 | | (list state))))))) | |
1003 | | (bind-vals ((event-type event-payload) state) args | |
1004 | | (if (equal? event-type (literal readln)) | |
1005 | | (if (equal? state 68) | |
1006 | | (list state (list (literal stop) 0)) | |
1007 | | (list (inc state) (list (literal writeln) event-payload))) | |
1008 | | (list state))))) | |
1028 | 1009 | | (reactor (line-terminal) 65 |
1029 | 1010 | | (macro (args env) |
1030 | | (bind-vals (event state) args | |
1031 | | (bind event-type (head event) | |
1032 | | (bind event-payload (head (tail event)) | |
1033 | | (if (equal? event-type (literal readln)) | |
1034 | | (list (inc state) (list (literal writeln) (list state))) | |
1035 | | (list state))))))) | |
1011 | | (bind-vals ((event-type event-payload) state) args | |
1012 | | (if (equal? event-type (literal readln)) | |
1013 | | (list (inc state) (list (literal writeln) (list state))) | |
1014 | | (list state))))) | |
1036 | 1015 | + Cat |
1037 | 1016 | + Dog |
1038 | 1017 | + Giraffe |