Add two simple tests for save. Surprisingly, they both pass.
Chris Pressey
4 years ago
1939 | 1939 | |
1940 | 1940 | ### save ### |
1941 | 1941 | |
1942 | Basic neutral test. | |
1942 | Basic neutral test, where the `save` makes no difference. | |
1943 | 1943 | |
1944 | 1944 | | routine main |
1945 | 1945 | | inputs a, x |
1946 | 1946 | | outputs a, x |
1947 | 1947 | | trashes z, n |
1948 | 1948 | | { |
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 | |
1949 | 1966 | | save x { |
1950 | 1967 | | 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 | |
1954 | 1989 | |
1955 | 1990 | ### copy ### |
1956 | 1991 |