From 0f41857b393d5a6c1a7e0d8885f28bc87850243d Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Fri, 20 Apr 2018 13:36:08 +0100 Subject: [PATCH] Add two simple tests for save. Surprisingly, they both pass. --- tests/SixtyPical Analysis.md | 37 +++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/SixtyPical Analysis.md b/tests/SixtyPical Analysis.md index f35d667..f8d2f4f 100644 --- a/tests/SixtyPical Analysis.md +++ b/tests/SixtyPical Analysis.md @@ -1940,19 +1940,54 @@ initialized at the start of that loop. ### save ### -Basic neutral test. +Basic neutral test, where the `save` makes no difference. | routine main | inputs a, x | outputs a, x | trashes z, n | { + | ld a, 1 + | save x { + | ld a, 2 + | } + | ld a, 3 + | } + = ok + +A defined value that has been saved can be trashed inside the block. +It will continue to be defined outside the block. + + | routine main + | inputs a + | outputs a, x + | trashes z, n + | { + | ld x, 0 | save x { | ld a, 0 + | trash x | } | } = ok +A trashed value that has been saved can be used inside the block. +It will continue to be trashed outside the block. + + | routine main + | inputs a + | outputs a, x + | trashes z, n + | { + | ld x, 0 + | trash x + | save x { + | ld a, 0 + | ld x, 1 + | } + | } + ? UnmeaningfulOutputError: x + ### copy ### Can't `copy` from a memory location that isn't initialized.