Skip to content

Commit 53bd51d

Browse files
committed
Test marshalling compression only when enabled
1 parent 7221b9c commit 53bd51d

File tree

3 files changed

+43
-23
lines changed

3 files changed

+43
-23
lines changed

compiler/tests-jsoo/dune

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,21 @@
99
(preprocess
1010
(pps ppx_expect)))
1111

12+
(library
13+
(name jsoo_testsuite_compression)
14+
(modules test_marshal_compressed)
15+
(libraries unix compiler-libs.common js_of_ocaml-compiler)
16+
(enabled_if
17+
(>= %{ocaml_version} 5.1.1))
18+
(inline_tests
19+
(modes js best))
20+
(preprocess
21+
(pps ppx_expect)))
22+
1223
(library
1324
(name jsoo_testsuite)
1425
(modules
15-
(:standard \ test_io test_floats))
26+
(:standard \ test_io test_floats test_marshal_compressed))
1627
(libraries unix compiler-libs.common js_of_ocaml-compiler)
1728
(foreign_stubs
1829
(language c)

compiler/tests-jsoo/test_marshal.ml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -134,28 +134,6 @@ let%expect_test _ =
134134
[%expect
135135
{| "\132\149\166\190\000\000\000'\000\000\000\001\000\000\000\007\000\000\000\007\024_bigarr02\000\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\001\000\000\000\005\000\003\000\003\000\001\000\002" |}]
136136

137-
let%expect_test _ =
138-
let data =
139-
"\132\149\166\189\r\022\206\021\001\147F\137d(\181/\253\000Xm\000\0000\n\
140-
\000\000'\016c\001\000\012\135\007E"
141-
in
142-
let ocaml_5_1 =
143-
match String.split_on_char '.' Sys.ocaml_version with
144-
| major :: minor :: _ ->
145-
let major = int_of_string major and minor = int_of_string minor in
146-
major > 5 || (major = 5 && minor >= 1)
147-
| _ -> assert false
148-
in
149-
let s =
150-
(* This would only work on OCaml 5.1.0 if we were not linking
151-
against compiler-libs *)
152-
if ocaml_5_1 && not (Sys.win32 || Sys.cygwin)
153-
then Marshal.from_string data 0
154-
else String.make 10000 'c'
155-
in
156-
Printf.printf "%s ... (%d)\n" (String.sub s 0 20) (String.length s);
157-
[%expect {| cccccccccccccccccccc ... (10000) |}]
158-
159137
let%expect_test "test sharing of string" =
160138
let s = "AString" in
161139
let p = s, s in
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
(* Js_of_ocaml tests
2+
* http://www.ocsigen.org/js_of_ocaml/
3+
* Copyright (C) 2019 Shachar Itzhaky
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, with linking exception;
8+
* either version 2.1 of the License, or (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program; if not, write to the Free Software
17+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18+
*)
19+
20+
let%expect_test _ =
21+
let data =
22+
"\132\149\166\189\r\022\206\021\001\147F\137d(\181/\253\000Xm\000\0000\n\
23+
\000\000'\016c\001\000\012\135\007E"
24+
in
25+
let s =
26+
if Compression.compression_supported
27+
then Marshal.from_string data 0
28+
else String.make 10000 'c'
29+
in
30+
Printf.printf "%s ... (%d)\n" (String.sub s 0 20) (String.length s);
31+
[%expect {| cccccccccccccccccccc ... (10000) |}]

0 commit comments

Comments
 (0)