$SPAD/src/input cwmmt.input

Timothy Daly December 3, 2016

Abstract

Contents

1 License

— license —

--Copyright The Numerical Algorithms Group Limited 1991.

———-

— cwmmt.spad —

--Note that the chunk enviroment allows math mode \(x^2+y^2=z^2\)
--It also allows other latex commands such as {\bf bold}.
)abbrev domain CWMMT CompWithMappingModeTest
CompWithMappingModeTest() : Exports == Implementation where
Exports == with
runTests : () -> Boolean
Implementation == add
REC ==> Record(field1 : Integer, field2 : String)
UN  ==> Union(rec : REC, str : String)
-- The following function accepts a map as argument to test
-- compWithMappingMode.
mapper(fn : Integer -> Boolean, n: Integer) : Boolean == fn n
-- We use the following as a target for currying and to pass to
-- mapper above.
pred(x: Integer, y: Integer) : Boolean ==
  x < y => true
  true
test1(x : Integer) : Boolean ==
   r : REC := [1, ""]
   mapper(pred(r.field1, #1), 1)
test2(x : Integer) : Boolean ==
   r : REC := [1, ""]
   i : Integer := 1
   mapper(pred(r.field1 + x, #1), 1)
test3(x : Integer) : Boolean ==

r : REC := [1, ""]
i : Integer := 1
mapper(pred(r.field1 + i, #1), 1)
test4(x : Integer) : Boolean ==
r : REC := [1, ""]
i : Integer := 1
mapper(pred((r.field1 + min(#(r.field2), i)), #1), 1)
test5(x : Integer) : Boolean ==
r : REC := [1, ""]
i : Integer := 1
mapper(pred((r.field1 + min(#(r.field2), i + x)), #1), 1)
test6(x : Integer) : Boolean ==
u : UN := [ [1, ""]$REC]
mapper(pred(u.rec.field1, #1), 1)
test7(x : Integer) : Boolean ==
u : UN := [ [1, ""]$REC]
i : Integer := 1
mapper(pred(u.rec.field1 + x, #1), 1)
test8(x : Integer) : Boolean ==
u : UN := [ [1, ""]$REC]
i : Integer := 1
mapper(pred(u.rec.field1 + i, #1), 1)
test9(x : Integer) : Boolean ==
u : UN := [ [1, ""]$REC]
i : Integer := 1
mapper(pred((u.rec.field1 + min(#(u.rec.field2), i)), #1), 1)
test10(x : Integer) : Boolean ==
u : UN := [ [1, ""]$REC]
i : Integer := 1
mapper(pred((u.rec.field1 + min(#(u.rec.field2), i + x)), #1), 1)
runTests() : Boolean ==
test1(1) and test2(1) and test3(1) _
         and test4(1) and test5(1) _
         and test6(1) and test7(1) _
         and test8(1) and test9(1) _
         and test10(1)

———-

— * —

)set break resume

)spool cwmmt.output
)sys cp $AXIOM/../../src/input/cwmmt.input.pamphlet .
)lisp (tangle "cwmmt.input.pamphlet" "cwmmt.spad" "cwmmt.spad" )
)co cwmmt.spad
)set message test on
)set message auto off
)clear all
--S 1 of 1
runTests()
--R
--R   (1)  true
--R                                                                Type: Boolean
--E 1
)spool
)lisp (bye)

———-

References^{[1] nothing}

5