File: members-ctree.fs

package info (click to toggle)
fsharp 4.0.0.4%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 58,824 kB
  • ctags: 1,395
  • sloc: cs: 2,983; ml: 1,098; makefile: 410; sh: 409; xml: 113
file content (73 lines) | stat: -rw-r--r-- 1,406 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// #Conformance #MemberDefinitions 
#if ALL_IN_ONE
module Core_members_ctree
#endif

let failures = ref []

let report_failure (s : string) = 
    stderr.Write" NO: "
    stderr.WriteLine s
    failures := !failures @ [s]

let test (s : string) b = 
    stderr.Write(s)
    if b then stderr.WriteLine " OK"
    else report_failure (s)

let check s b1 b2 = test s (b1 = b2)

module CTree1 = begin

type 'a ctree = 
  class 
    val isLeaf: bool
    val leafVal: 'a option
    val children: 'a ctree list

    new(x : 'a) = { isLeaf = true; leafVal = Some(x); children = [] }
    
    new((dummy : bool) , (l : 'a ctree list)) = { isLeaf = false; leafVal = None; children = l }

    static member MkNode(l : 'a ctree list) = new ctree<_>(true, l)

  end
 

end

module CTree2 = begin



type 'a ctree = 
  class 
    val isLeaf: bool
    val leafVal: 'a option
    val children: 'a ctree list

    new(x : 'a) = { isLeaf = true; leafVal = Some(x); children = [] }
    
    new((dummy : bool) , (l : 'a ctree list)) = { isLeaf = false; leafVal = None; children = l }

    static member MkNode(l : 'a ctree list) = new ctree<_>(true, l)

  end
 
end


#if ALL_IN_ONE
let RUN() = !failures
#else
let aa =
  match !failures with 
  | [] -> 
      stdout.WriteLine "Test Passed"
      System.IO.File.WriteAllText("test.ok","ok")
      exit 0
  | _ -> 
      stdout.WriteLine "Test Failed"
      exit 1
#endif