standalone exapunks vm in ocaml
1(* This Source Code Form is subject to the terms of the Mozilla Public
2 License, v. 2.0. If a copy of the MPL was not distributed with this
3 file, You can obtain one at https://mozilla.org/MPL/2.0/. *)
4
5open Exapunks
6open Helpers
7
8let () = set_context __FILE__
9
10let () =
11 describe "#void" (fun () ->
12 specify "negative" (fun () ->
13 let f1 = File.create "200" ~contents:[ Int 72; Int 52; Int 4; Int 60 ] in
14 File.void f1 ~-1;
15 let f2 = File.create "200" ~contents:[ Int 72; Int 52; Int 4; Int 60 ] in
16 Alcotest.check t_file "" f2 f1);
17
18 specify "start" (fun () ->
19 let f1 = File.create "200" ~contents:[ Int 72; Int 52; Int 4; Int 60 ] in
20 File.void f1 0;
21 let f2 = File.create "200" ~contents:[ Int 52; Int 4; Int 60 ] in
22 Alcotest.check t_file "" f2 f1);
23
24 specify "middle" (fun () ->
25 let f1 = File.create "200" ~contents:[ Int 72; Int 52; Int 4; Int 60 ] in
26 File.void f1 2;
27 let f2 = File.create "200" ~contents:[ Int 72; Int 52; Int 60 ] in
28 Alcotest.check t_file "" f2 f1);
29
30 specify "end" (fun () ->
31 let f1 = File.create "200" ~contents:[ Int 72; Int 52; Int 4; Int 60 ] in
32 File.void f1 3;
33 let f2 = File.create "200" ~contents:[ Int 72; Int 52; Int 4 ] in
34 Alcotest.check t_file "" f2 f1);
35
36 specify "past end" (fun () ->
37 let f1 = File.create "200" ~contents:[ Int 72; Int 52; Int 4; Int 60 ] in
38 File.void f1 10;
39 let f2 = File.create "200" ~contents:[ Int 72; Int 52; Int 4; Int 60 ] in
40 Alcotest.check t_file "" f2 f1);
41 ())