mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-05 22:38:44 +00:00
Added test18 on cyclic equality
This commit is contained in:
parent
026158923f
commit
6f9d0850c7
3 changed files with 99 additions and 2 deletions
32
stdlib/regression/orig/test18.log
Normal file
32
stdlib/regression/orig/test18.log
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
1 =?= 1 = 0
|
||||
symmetricity: ok
|
||||
1 =?= 10 = -1
|
||||
symmetricity: ok
|
||||
"abc" =?= "abc" = 0
|
||||
symmetricity: ok
|
||||
"abc" =?= "def" = -1
|
||||
symmetricity: ok
|
||||
1 =?= "abc" = 1
|
||||
symmetricity: ok
|
||||
S (1) =?= S (1) = 0
|
||||
symmetricity: ok
|
||||
S (2) =?= S (1) = 1
|
||||
symmetricity: ok
|
||||
S (1, 2, 3) =?= S (1, 3, 2) = -1
|
||||
symmetricity: ok
|
||||
S (1, 2, 3) =?= D (5, 6) = 1
|
||||
symmetricity: ok
|
||||
1 =?= S (5) = 1
|
||||
symmetricity: ok
|
||||
"abs" =?= S (5, 6) = -1
|
||||
symmetricity: ok
|
||||
[1, 2, 3] =?= S (1, 2, 3) = -1
|
||||
symmetricity: ok
|
||||
"abc" =?= [1, 2, 3] = -1
|
||||
symmetricity: ok
|
||||
1 =?= [1, 2, 3] = 1
|
||||
symmetricity: ok
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
65
stdlib/regression/test18.lama
Normal file
65
stdlib/regression/test18.lama
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import Data;
|
||||
|
||||
fun normalize (x) {
|
||||
if x == 0 then 0
|
||||
elif x < 0 then -1
|
||||
else 1
|
||||
fi
|
||||
}
|
||||
|
||||
fun not (x) {
|
||||
0 - x
|
||||
}
|
||||
|
||||
fun test (a, b) {
|
||||
local f = normalize (a =?= b);
|
||||
|
||||
printf ("%s =?= %s = %d\n", a.string, b.string, f);
|
||||
printf ("symmetricity: %s\n", if normalize (b =?= a) == not (f) then "ok" else "fail" fi)
|
||||
}
|
||||
|
||||
test (1, 1);
|
||||
test (1, 10);
|
||||
|
||||
test ("abc", "abc");
|
||||
test ("abc", "def");
|
||||
|
||||
test (1, "abc");
|
||||
|
||||
test (S (1), S (1));
|
||||
test (S (2), S (1));
|
||||
test (S (1, 2, 3), S (1, 3, 2));
|
||||
test (S (1, 2, 3), D (5, 6));
|
||||
|
||||
test (1, S (5));
|
||||
test ("abs", S (5, 6));
|
||||
test ([1, 2, 3], S (1, 2, 3));
|
||||
test ("abc", [1, 2, 3]);
|
||||
test (1, [1, 2, 3]);
|
||||
|
||||
{
|
||||
local a = [1], b = [1];
|
||||
|
||||
a [0] := a;
|
||||
b [0] := b;
|
||||
|
||||
printf ("%d\n", a =?= b);
|
||||
|
||||
a[0] := b;
|
||||
b[0] := a;
|
||||
|
||||
printf ("%d\n", a =?= b);
|
||||
|
||||
a := S (1);
|
||||
b := S (1);
|
||||
|
||||
a[0] := a;
|
||||
b[0] := b;
|
||||
|
||||
printf ("%d\n", a =?= b);
|
||||
|
||||
a[0] := b;
|
||||
b[0] := a;
|
||||
|
||||
printf ("%d\n", a =?= b)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue