From 86e048f698ab10c46117dc5a75d7d1c6a3be5a1c Mon Sep 17 00:00:00 2001 From: Peter W A Wood Date: Mon, 27 Feb 2012 15:16:33 +0800 Subject: [PATCH] TESTS: added tests to reflect issue #208 in float-test.reds and float32-test.reds --- red-system/tests/source/units/float-test.reds | 40 ++++++++++++++++++ .../tests/source/units/float32-test.reds | 41 ++++++++++++++++++- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/red-system/tests/source/units/float-test.reds b/red-system/tests/source/units/float-test.reds index 2765cf4f26..9101e696a0 100644 --- a/red-system/tests/source/units/float-test.reds +++ b/red-system/tests/source/units/float-test.reds @@ -237,4 +237,44 @@ Red/System [ ===end-group=== +===start-group=== "float arguments to typed functions" + fatf1: function [ + [typed] + count [integer!] + list [typed-value!] + return: [float!] + /local + a [float!] + ][ + a: as float! list/value + ] + + fatf2: function [ + [typed] + count [integer!] + list [typed-value!] + return: [float!] + /local + a [float!] + b [float!] + ][ + a: as float! list/value + list: list + 1 + b: as float! list/value + a + b + ] + + --test-- "fatf-1" + --assert 2.0 = fatf1 2.0 + + --test-- "fatf-2" + --assert 2.0 = fatf1 1.0 + fatf1 1.0 + + --test-- "fatf-3" + --assert 3.0 = fatf2 1.0 2.0 + + +===end-group=== + + ~~~end-file~~~ diff --git a/red-system/tests/source/units/float32-test.reds b/red-system/tests/source/units/float32-test.reds index abd4350f87..21c3f77ed9 100644 --- a/red-system/tests/source/units/float32-test.reds +++ b/red-system/tests/source/units/float32-test.reds @@ -215,7 +215,7 @@ Red/System [ as float32! 2.0 ] - --test-- "ewrfv0" + --test-- "ewrfv0" --assertf32~= as float32! 1.0 (fe1 * as float32! 1.0) as float32! 0.1E-3 --test-- "ewrfv1" @@ -226,5 +226,44 @@ Red/System [ ===end-group=== +===start-group=== "float32 arguments to typed functions" + fatf1: function [ + [typed] + count [integer!] + list [typed-value!] + return: [float32!] + /local + a [float32!] + ][ + a: as float32! list/value + ] + + fatf2: function [ + [typed] + count [integer!] + list [typed-value!] + return: [float32!] + /local + a [float32!] + b [float32!] + ][ + a: as float32! list/value + list: list + 1 + b: as float32! list/value + a + b + ] + + --test-- "fatf-1" + --assert (as float32! 2.0) = (fatf1 as float32! 2.0) + + --test-- "fatf-2" + --assert (as float32! 2.0) = ((fatf1 as float32! 1.0) + (fatf1 as float32! 1.0)) + + --test-- "fatf-3" + --assert (as float32! 3.0) = fatf2 as float32! 1.0 as float! 2.0 + + +===end-group=== + ~~~end-file~~~