-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from mbarbin/add-tests
Add tests
- Loading branch information
Showing
10 changed files
with
83 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
let loc = Loc.in_file ~path:(Fpath.v "file") | ||
|
||
let%expect_test "to_string" = | ||
print_endline (Loc.to_string loc); | ||
[%expect {| File "file", line 1, characters 0-0: |}]; | ||
print_endline (Loc.to_file_colon_line loc); | ||
[%expect {| file:1 |}]; | ||
() | ||
;; | ||
|
||
let%expect_test "path" = | ||
print_endline (Loc.path loc |> Fpath.to_string); | ||
[%expect {| file |}]; | ||
() | ||
;; | ||
|
||
let%expect_test "start_line" = | ||
print_s [%sexp (Loc.start_line loc : int)]; | ||
[%expect {| 1 |}]; | ||
() | ||
;; | ||
|
||
let%expect_test "is_none" = | ||
print_s [%sexp (Loc.is_none loc : bool)]; | ||
[%expect {| false |}]; | ||
() | ||
;; | ||
|
||
let%expect_test "range" = | ||
print_s [%sexp (Loc.range loc : Loc.Range.t)]; | ||
[%expect {| | ||
((start 0) | ||
(stop 0)) | ||
|}]; | ||
() | ||
;; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
let p1 = [%here] | ||
let p2 = [%here] | ||
let equal_position (a : Lexing.position) (b : Lexing.position) = Stdlib.compare a b = 0 | ||
|
||
let%expect_test "equal" = | ||
let r1 = Loc.create (p1, p2) in | ||
require [%here] (equal_position (Loc.start r1) p1); | ||
[%expect {||}]; | ||
require [%here] (equal_position (Loc.stop r1) p2); | ||
[%expect {||}]; | ||
require [%here] (not (equal_position (Loc.start r1) p2)); | ||
[%expect {||}]; | ||
require [%here] (not (equal_position (Loc.stop r1) p1)); | ||
[%expect {||}]; | ||
() | ||
;; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
let%expect_test "1 line" = | ||
let loc = | ||
Loc.create | ||
( { Lexing.pos_fname = "file"; pos_lnum = 1; pos_cnum = 2; pos_bol = 0 } | ||
, { Lexing.pos_fname = "file"; pos_lnum = 1; pos_cnum = 10; pos_bol = 0 } ) | ||
in | ||
print_endline (Loc.to_string loc); | ||
[%expect {| File "file", line 1, characters 2-10: |}]; | ||
() | ||
;; | ||
|
||
let%expect_test "multiple lines" = | ||
let loc = | ||
Loc.create | ||
( { Lexing.pos_fname = "file"; pos_lnum = 1; pos_cnum = 2; pos_bol = 0 } | ||
, { Lexing.pos_fname = "file"; pos_lnum = 3; pos_cnum = 35; pos_bol = 30 } ) | ||
in | ||
print_endline (Loc.to_string loc); | ||
[%expect {| File "file", lines 1-3, characters 2-35: |}]; | ||
() | ||
;; |
Empty file.