Commit 31dbc0df authored by Laszlo Domoszlai's avatar Laszlo Domoszlai
Browse files

update tests

parent 82ae8ebc
module Adjoxo;
import Flite;
:: Side = X | O;
:: Result = Win | Draw | Loss;
map f Nil = Nil;
map f (Cons x xs) = Cons (f x) (map f xs);
bestOf Win v = Win;
bestOf Loss v = v;
bestOf Draw Win = Win;
bestOf Draw Draw = Draw;
bestOf Draw Loss = Draw;
inverse Loss = Win;
inverse Draw = Draw;
inverse Win = Loss;
fromTo n m = case (<=) n m of {
True -> Cons n (fromTo ((+) n 1) m);
False -> Nil;
};
cmp a b =
case (==) a b of {
True -> EQ;
False -> case (<=) a b of { True -> LT ; False -> GT };
};
insert x Nil = Cons x Nil;
insert x (Cons y ys) = case (<=) x y of {
True -> Cons x (Cons y ys);
False -> Cons y (insert x ys);
};
foldr1 f (Cons x Nil) = x;
foldr1 f (Cons x (Cons y ys)) = f x (foldr1 f (Cons y ys));
diff Nil ys = Nil;
diff (Cons x xs) Nil = Cons x xs;
diff (Cons x xs) (Cons y ys) =
case cmp x y of {
LT -> Cons x (diff xs (Cons y ys));
EQ -> diff xs ys;
GT -> diff (Cons x xs) ys;
};
null Nil = True;
null (Cons x xs) = False;
subset xs ys = null (diff xs ys);
or False x = x;
or True x = True;
hasLine p =
or (subset (Cons 1 (Cons 2 (Cons 3 Nil))) p)
(or (subset (Cons 4 (Cons 5 (Cons 6 Nil))) p)
(or (subset (Cons 7 (Cons 8 (Cons 9 Nil))) p)
(or (subset (Cons 1 (Cons 4 (Cons 7 Nil))) p)
(or (subset (Cons 2 (Cons 5 (Cons 8 Nil))) p)
(or (subset (Cons 3 (Cons 6 (Cons 9 Nil))) p)
(or (subset (Cons 1 (Cons 5 (Cons 9 Nil))) p)
(subset (Cons 3 (Cons 5 (Cons 7 Nil))) p)))))));
len Nil = 0;
len (Cons x xs) = (+) 1 (len xs);
gridFull ap pp = (==) ((+) (len ap) (len pp)) 9;
analysis ap pp =
case hasLine pp of {
True -> Loss;
False ->
case gridFull ap pp of {
True -> Draw;
False -> foldr1 bestOf (map (moveval ap pp)
(diff (diff (fromTo 1 9) ap) pp));
};
};
moveval ap pp m = inverse (analysis pp (insert m ap));
adjudicate os xs =
case cmp (len os) (len xs) of {
GT -> report (analysis xs os) X;
EQ -> case hasLine xs of {
True -> report Win X;
False -> case hasLine os of {
True -> report Win O;
False -> report (analysis xs os) X;
};
};
LT -> report (analysis os xs) O;
};
report Loss s = side (opp s);
report Win s = side s;
report Draw p = 'D';
opp O = X;
opp X = O;
side O = 'O';
side X = 'X';
Start = adjudicate Nil Nil;
Version: 1.4
Global
ProjectRoot: .
Target: iTasks
Exec: {Project}\Adjoxo.exe
CodeGen
CheckStacks: False
CheckIndexes: True
Application
HeapSize: 2097152
StackSize: 512000
ExtraMemory: 81920
IntialHeapSize: 204800
HeapSizeMultiplier: 4096
ShowExecutionTime: True
ShowGC: False
ShowStackSize: False
MarkingCollector: False
StandardRuntimeEnv: True
Profile
Memory: False
MemoryMinimumHeapSize: 10485760
Time: False
Stack: False
Output
Output: ShowConstructors
Font: Courier
FontSize: 9
WriteStdErr: False
Link
LinkMethod: Static
GenerateRelocations: False
GenerateLinkMap: False
LinkResources: False
ResourceSource:
GenerateDLL: False
ExportedNames:
Paths
Path: {Project}
Precompile:
Postlink:
MainModule
Name: Adjoxo
Dir: {Project}
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: InferredTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
OtherModules
Module
Name: Flite
Dir: {Project}
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdArray
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdBool
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdChar
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdCharList
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdClass
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdDebug
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdEnum
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdEnv
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdFile
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdFunc
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdInt
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdList
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdMisc
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdOrdList
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdOverloaded
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdReal
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdString
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdTuple
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: _SystemArray
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: _SystemEnum
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: _SystemDynamic
Dir: {Application}\iTasks-SDK\Patches\Dynamics
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
module Braun;
import Flite;
:: Tree a = Empty | Branch a (Tree a) (Tree a);
insert x Empty = Branch x Empty Empty;
insert x (Branch y t0 t1) = Branch x (insert y t1) t0;
and False y = False;
and True y = y;
size Empty = 0;
size (Branch x t0 t1) = (+) 1 ((+) (size t0) (size t1));
fromList Nil = Empty;
fromList (Cons x xs) = insert x (fromList xs);
toList Empty = Nil;
toList (Branch x t0 t1) = Cons x (ilv (toList t0) (toList t1));
ilv Nil ys = ys;
ilv (Cons x xs) Nil = Cons x xs;
ilv (Cons x xs) (Cons y ys) = Cons x (Cons y (ilv xs ys));
replicate n x = if ((==) n 0) Nil (Cons x (replicate ((-) n 1) x));
fromTo n m = case (<=) n m of {
True -> Cons n (fromTo ((+) n 1) m);
False -> Nil;
};
repeat x = Cons x (repeat x);
equal Nil Nil = True;
equal Nil (Cons y ys) = False;
equal (Cons x xs) Nil = False;
equal (Cons x xs) (Cons y ys) =
case (==) x y of {
False -> False;
True -> equal xs ys;
};
prop xs = equal xs (toList (fromList xs));
all p Nil = True;
all p (Cons x xs) = and (p x) (all p xs);
int True = 1;
int False = 0;
Start = int (all prop (replicate 6000 (fromTo 0 255)));
Version: 1.4
Global
ProjectRoot: .
Target: iTasks
Exec: {Project}\Braun.exe
CodeGen
CheckStacks: False
CheckIndexes: True
Application
HeapSize: 2097152
StackSize: 512000
ExtraMemory: 81920
IntialHeapSize: 204800
HeapSizeMultiplier: 4096
ShowExecutionTime: True
ShowGC: False
ShowStackSize: False
MarkingCollector: False
StandardRuntimeEnv: True
Profile
Memory: False
MemoryMinimumHeapSize: 0
Time: False
Stack: False
Output
Output: ShowConstructors
Font: Courier
FontSize: 9
WriteStdErr: False
Link
LinkMethod: Static
GenerateRelocations: False
GenerateLinkMap: False
LinkResources: False
ResourceSource:
GenerateDLL: False
ExportedNames:
Paths
Path: {Project}
Precompile:
Postlink:
MainModule
Name: Braun
Dir: {Project}
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
OtherModules
Module
Name: Flite
Dir: {Project}
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: StdArray
Dir: {Application}\Libraries\StdEnv
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False