File: cpath_test.md

package info (click to toggle)
ocaml-odoc 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,008 kB
  • sloc: ml: 60,567; javascript: 2,572; sh: 566; makefile: 31
file content (34 lines) | stat: -rw-r--r-- 1,391 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
```ocaml env=e1
open Odoc_model.Names
```

### Hidden paths

Tests for `weak_canonical_test`. When calling `is_resolved_module_hidden`, we normally would have `weak_canonical_test` false, and we'll check to see whether the canonical part of a path is hidden or not. When `weak_canonical_test` is true, we'll _assume_ that the canonical part will resolve to be a non-hidden path.

In the following test, we create a path with an unresolved canonical 
```ocaml env=e1
# let m = `Hidden (`Local (`LModule (ModuleName.hidden_of_string "M", 1)));;
val m : [> `Hidden of [> `Local of [> `LModule of ModuleName.t * int ] ] ] =
  `Hidden (`Local (`LModule (M, 1)))
# let cm = `Root (ModuleName.make_std "Foo");;
val cm : [> `Root of ModuleName.t ] = `Root Foo
# let p = `Canonical(m, cm);;
val p :
  [> `Canonical of
       [> `Hidden of [> `Local of [> `LModule of ModuleName.t * int ] ] ] *
       [> `Root of ModuleName.t ] ] =
  `Canonical (`Hidden (`Local (`LModule (M, 1))), `Root Foo)
```

At this point, `p` is a path to a hidden module that has an unresolved canonical constructor

In the following test, the when `weak_canonical_test` is true, the path should _not_ be hidden.

```ocaml env=e1
# let r1 = Cpath.is_resolved_module_hidden ~weak_canonical_test:false p;;
val r1 : bool = true
# let r2 = Cpath.is_resolved_module_hidden ~weak_canonical_test:true p;;
val r2 : bool = false
```