Skip to content

Commit

Permalink
Improve tests for lint 'mutability_check'
Browse files Browse the repository at this point in the history
Signed-off-by: Kakadu <[email protected]>
  • Loading branch information
Kakadu committed Jul 28, 2024
1 parent 6eb0284 commit 1e7c6e0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/typed/hashtables.t/.zanuda
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
forward mutability_check ignore tast.ml,tast.ml,tast.ml,tast.ml
3 changes: 3 additions & 0 deletions tests/typed/hashtables.t/Counter.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let count =
let last = ref 0 in
(fun () -> incr last; !last)
2 changes: 1 addition & 1 deletion tests/typed/hashtables.t/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
(name test_hashtables)
(wrapped false)
(libraries base)
(modules Hashtables))
(modules Hashtables Counter Tast))
8 changes: 8 additions & 0 deletions tests/typed/hashtables.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@
24 | type args = { mutable count: int }
^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "Counter.ml", line 3, characters 18-22:
3 | (fun () -> incr last; !last)
^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "Counter.ml", line 3, characters 25-29:
3 | (fun () -> incr last; !last)
^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
3 changes: 3 additions & 0 deletions tests/typed/hashtables.t/tast.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(** Report about this line will not appear because of .zanuda file *)
let last = ref 0
let() = incr last

0 comments on commit 1e7c6e0

Please sign in to comment.