Port ML tests from partial to strict
[hiphop-php.git] / hphp / hack / test / integration_ml / test_new_file.ml
blob78b5de9c7f8c128d491f21bb5e6a5b80ff939bc4
1 (*
2 * Copyright (c) 2016, Facebook, Inc.
3 * All rights reserved.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
9 *)
11 open Integration_test_base_types
12 open ServerEnv
13 open Hh_prelude
14 module Test = Integration_test_base
16 let foo_contents = "<?hh
21 let test () =
22 let env = Test.setup_server () in
23 let (env, loop_output) =
24 Test.(
25 run_loop_once
26 env
27 { default_loop_input with disk_changes = [("foo.php", foo_contents)] })
29 if not loop_output.did_read_disk_changes then
30 Test.fail "Expected the server to process disk updates";
31 let expected_errors =
33 "File \"/foo.php\", line 3, characters 1-1:\n"
34 ^ "Toplevel statements are not allowed. Use `__EntryPoint` attribute instead (Parsing[1002])";
35 "File \"/foo.php\", line 3, characters 2-2:\n"
36 ^ "A right brace `}` is expected here. (Parsing[1002])\n";
39 match List.zip expected_errors (Errors.get_error_list env.errorl) with
40 | List.Or_unequal_lengths.Ok errs ->
41 List.iter
42 ~f:(fun (expected, err) -> Test.assertSingleError expected [err])
43 errs
44 | List.Or_unequal_lengths.Unequal_lengths -> Test.fail "Expected 2 errors."