git @ Cat's Eye Technologies SixtyPical / d037401
Add three tests. One fails when it shouldn't. Chris Pressey 3 years ago
1 changed file(s) with 59 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
20152015 | }
20162016 ? UnmeaningfulOutputError: x
20172017
2018 The known range of a value will be preserved outside the block as well.
2019
2020 | word one: 77
2021 | word table[32] many
2022 |
2023 | routine main
2024 | inputs a, many, one
2025 | outputs many, one
2026 | trashes a, x, n, z
2027 | {
2028 | and a, 31
2029 | ld x, a
2030 | save x {
2031 | ld x, 255
2032 | }
2033 | copy one, many + x
2034 | copy many + x, one
2035 | }
2036 = ok
2037
2038 | word one: 77
2039 | word table[32] many
2040 |
2041 | routine main
2042 | inputs a, many, one
2043 | outputs many, one
2044 | trashes a, x, n, z
2045 | {
2046 | and a, 63
2047 | ld x, a
2048 | save x {
2049 | ld x, 1
2050 | }
2051 | copy one, many + x
2052 | copy many + x, one
2053 | }
2054 ? RangeExceededError
2055
2056 The known properties of a value are preserved inside the block, too.
2057
2058 | word one: 77
2059 | word table[32] many
2060 |
2061 | routine main
2062 | inputs a, many, one
2063 | outputs many, one
2064 | trashes a, x, n, z
2065 | {
2066 | and a, 31
2067 | ld x, a
2068 | save x {
2069 | copy one, many + x
2070 | copy many + x, one
2071 | }
2072 | copy one, many + x
2073 | copy many + x, one
2074 | }
2075 = ok
2076
20182077 A value which is not output from the routine, is preserved by the
20192078 routine; and can appear in a `save` exactly because a `save` preserves it.
20202079