From f8cfaedc84c3a711544f07e8e1868233e686da6d Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Sat, 14 Jan 2023 18:31:33 -0800 Subject: [PATCH] Adding tests for faults. --- common/all_tests.fs | 1 + common/fault_tests.fs | 64 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 common/fault_tests.fs diff --git a/common/all_tests.fs b/common/all_tests.fs index 6bb056e..ba366ef 100644 --- a/common/all_tests.fs +++ b/common/all_tests.fs @@ -24,6 +24,7 @@ needs conditionals_tests.fs needs float_tests.fs needs forth_namespace_tests.fs needs structures_tests.fs +needs fault_tests.fs needs including_tests/including_tests.fs needs modules_tests.fs needs ../lib/hashing/sha1_tests.fs diff --git a/common/fault_tests.fs b/common/fault_tests.fs new file mode 100644 index 0000000..e8fe759 --- /dev/null +++ b/common/fault_tests.fs @@ -0,0 +1,64 @@ +\ Copyright 2022 Bradley D. Nelson +\ +\ Licensed under the Apache License, Version 2.0 (the "License"); +\ you may not use this file except in compliance with the License. +\ You may obtain a copy of the License at +\ +\ http://www.apache.org/licenses/LICENSE-2.0 +\ +\ Unless required by applicable law or agreed to in writing, software +\ distributed under the License is distributed on an "AS IS" BASIS, +\ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +\ See the License for the specific language governing permissions and +\ limitations under the License. + +( Testing Memory Faults ) + +( Skip on ESP32 as not emulated. ) +DEFINED? esp 0= [IF] + +e: test-read-null + 0 ' @ catch assert drop +;e + +e: test-read-1023 + 1023 ' @ catch assert drop +;e + +e: test-read-1024 + 1024 ' @ catch assert drop +;e + +e: test-write-null + 123 0 ' ! catch assert 2drop +;e + +e: test-write-1023 + 123 1023 ' ! catch assert 2drop +;e + +e: test-write-1024 + 123 1024 ' ! catch assert 2drop +;e + +( Skip on win64 because wine can't handle these, unsure why. ) +DEFINED? windows 0= cell 4 = or [IF] + +e: test-call-null + internals + 0 ' call0 catch assert drop +;e + +e: test-call-1023 + internals + 1023 ' call0 catch assert drop +;e + +e: test-call-1024 + internals + 1024 ' call0 catch assert drop +;e + +[THEN] + +[THEN]