File: TestLicense.ml

package info (click to toggle)
oasis 0.4.4-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,432 kB
  • ctags: 2,908
  • sloc: ml: 31,357; makefile: 166; sh: 75; ansic: 48; awk: 26
file content (152 lines) | stat: -rw-r--r-- 4,613 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
(******************************************************************************)
(* OASIS: architecture for building OCaml libraries and applications          *)
(*                                                                            *)
(* Copyright (C) 2011-2013, Sylvain Le Gall                                   *)
(* Copyright (C) 2008-2011, OCamlCore SARL                                    *)
(*                                                                            *)
(* This library is free software; you can redistribute it and/or modify it    *)
(* under the terms of the GNU Lesser General Public License as published by   *)
(* the Free Software Foundation; either version 2.1 of the License, or (at    *)
(* your option) any later version, with the OCaml static compilation          *)
(* exception.                                                                 *)
(*                                                                            *)
(* This library is distributed in the hope that it will be useful, but        *)
(* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *)
(* or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more         *)
(* details.                                                                   *)
(*                                                                            *)
(* You should have received a copy of the GNU Lesser General Public License   *)
(* along with this library; if not, write to the Free Software Foundation,    *)
(* Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA              *)
(******************************************************************************)


(** Test for OASISLicense
    @author Sylvain Le Gall
  *)


open OUnit2
open TestCommon
open OASISValues
open OASISTypes
open OASISLicense


let tests =
  let ver =
    OASISVersion.version_of_string
  in
  let mk_base ?(v=NoVersion) ?e lic =
      (DEP5Unit
         {
           license  = lic;
           version  = v;
           excption = e;
         })
  in
  let mk ?v ?e lic =
    Some (DEP5License (mk_base ?v ?e lic))
  in

    "License" >:::
    (List.map
       (fun (txt, res) ->
          txt >::
          (fun test_ctxt ->
             match res with
               | Some exp ->
                   assert_equal
                     ~printer:(fun v -> Printf.sprintf "%S" (to_string v))
                     exp
                     (value.parse ~ctxt:oasis_ctxt txt)
               | None ->
                   try
                     ignore (value.parse ~ctxt:oasis_ctxt txt);
                     assert_failure
                       (Printf.sprintf
                          "License '%s' is not valid but parse without problem"
                          txt)
                   with e ->
                     ()))

       [
         "BSD-4-clause",
         mk bsd4;

         "BSD-4-clause-1.0+",
         None;
        
         (* TODO: Test also BSD3 because it was a deprecated synonym BSD-3-clause, same for 
            BSD2. *)

         "BSD-3-clause",
         mk bsd3;

         "BSD3",
         mk bsd3;

         "GPL",
         mk gpl;

         "GPL-2",
         mk ~v:(Version (ver "2")) gpl;

         "GPL-2+",
         mk ~v:(VersionOrLater (ver "2")) gpl;

         "LGPL-2.1 with OCaml linking exception",
         mk ~v:(Version (ver "2.1")) ~e:ocaml_linking_exception lgpl;

         "http://some.stuff.com/license",
         Some (OtherLicense "http://some.stuff.com/license");

         "CeCILL",
         mk cecill;

         "CeCILL-B",
         mk cecillb;

         "CeCILL-C",
         mk cecillc;

         "LGPL-2.1 with OCaml drinking exception",
         None;

         "CeCILLB2000",
         None;

         "CMU/MIT",
         None;

         "GPL-1+ or Artistic",
         Some
           (DEP5License
             (DEP5Or
                [
                  mk_base ~v:(VersionOrLater (ver "1")) gpl;
                  mk_base artistic;
                ]));

         "GPL-2+ and BSD-3-clause",
         Some
           (DEP5License
             (DEP5And
                [
                  mk_base ~v:(VersionOrLater (ver "2")) gpl;
                  mk_base bsd3;
                ]));

         "GPL-2+ or Artistic-2.0, and BSD-3-clause",
         Some
           (DEP5License
             (DEP5And
                [DEP5Or
                   [
                     mk_base ~v:(VersionOrLater (ver "2")) gpl;
                     mk_base ~v:(Version (ver "2.0")) artistic;
                   ];
                 mk_base bsd3]));
       ]

    )