git @ Cat's Eye Technologies SixtyPical / 0f41857
Add two simple tests for save. Surprisingly, they both pass. Chris Pressey 3 years ago
1 changed file(s) with 39 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
19391939
19401940 ### save ###
19411941
1942 Basic neutral test.
1942 Basic neutral test, where the `save` makes no difference.
19431943
19441944 | routine main
19451945 | inputs a, x
19461946 | outputs a, x
19471947 | trashes z, n
19481948 | {
1949 | ld a, 1
1950 | save x {
1951 | ld a, 2
1952 | }
1953 | ld a, 3
1954 | }
1955 = ok
1956
1957 A defined value that has been saved can be trashed inside the block.
1958 It will continue to be defined outside the block.
1959
1960 | routine main
1961 | inputs a
1962 | outputs a, x
1963 | trashes z, n
1964 | {
1965 | ld x, 0
19491966 | save x {
19501967 | ld a, 0
1951 | }
1952 | }
1953 = ok
1968 | trash x
1969 | }
1970 | }
1971 = ok
1972
1973 A trashed value that has been saved can be used inside the block.
1974 It will continue to be trashed outside the block.
1975
1976 | routine main
1977 | inputs a
1978 | outputs a, x
1979 | trashes z, n
1980 | {
1981 | ld x, 0
1982 | trash x
1983 | save x {
1984 | ld a, 0
1985 | ld x, 1
1986 | }
1987 | }
1988 ? UnmeaningfulOutputError: x
19541989
19551990 ### copy ###
19561991