-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add test for mel.as in mel.set external * fix mel.as test
- Loading branch information
Showing
1 changed file
with
101 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
Test the attribute @mel.as in external with @mel.set | ||
|
||
$ . ./setup.sh | ||
|
||
$ cat > x.ml <<\EOF | ||
> type document | ||
> | ||
> external document : document = "document" | ||
> | ||
> external transition : | ||
> document -> | ||
> [ `ease | ||
> | `easeIn [@mel.as "ease-in"] | ||
> | `easeOut [@mel.as "ease-out"] | ||
> | `easeInOut [@mel.as "ease-in-out"] | ||
> | `linear ] -> | ||
> unit = "transitionTimingFunction" | ||
> [@@mel.set] | ||
> | ||
> let () = transition document `easeIn | ||
> EOF | ||
$ cat > dune-project <<EOF | ||
> (lang dune 3.8) | ||
> (using melange 0.1) | ||
> EOF | ||
$ cat > dune <<EOF | ||
> (melange.emit | ||
> (target out) | ||
> (emit_stdlib false) | ||
> (preprocess (pps melange.ppx))) | ||
> EOF | ||
When `mel.string` is not used, the compiler complains | ||
$ dune build @melange | ||
File "x.ml", line 8, characters 14-20: | ||
8 | | `easeIn [@mel.as "ease-in"] | ||
^^^^^^ | ||
Alert unused: Unused attribute [@mel.as] | ||
This means such annotation is not annotated properly. | ||
For example, some annotations are only meaningful in externals | ||
File "x.ml", line 9, characters 15-21: | ||
9 | | `easeOut [@mel.as "ease-out"] | ||
^^^^^^ | ||
Alert unused: Unused attribute [@mel.as] | ||
This means such annotation is not annotated properly. | ||
For example, some annotations are only meaningful in externals | ||
File "x.ml", line 10, characters 17-23: | ||
10 | | `easeInOut [@mel.as "ease-in-out"] | ||
^^^^^^ | ||
Alert unused: Unused attribute [@mel.as] | ||
This means such annotation is not annotated properly. | ||
For example, some annotations are only meaningful in externals | ||
The `mel.as` attribute has no effect in the output | ||
$ cat ./_build/default/out/x.js | ||
// Generated by Melange | ||
'use strict'; | ||
document.transitionTimingFunction = "easeIn"; | ||
/* Not a pure module */ | ||
$ cat > x.ml <<\EOF | ||
> type document | ||
> | ||
> external document : document = "document" | ||
> | ||
> external transition : | ||
> document -> | ||
> ([ `ease | ||
> | `easeIn [@mel.as "ease-in"] | ||
> | `easeOut [@mel.as "ease-out"] | ||
> | `easeInOut [@mel.as "ease-in-out"] | ||
> | `linear ] [@mel.string]) -> | ||
> unit = "transitionTimingFunction" | ||
> [@@mel.set] | ||
> | ||
> let () = transition document `easeIn | ||
> EOF | ||
Using @mel.string fixes it | ||
$ dune build @melange | ||
$ cat ./_build/default/out/x.js | ||
// Generated by Melange | ||
'use strict'; | ||
document.transitionTimingFunction = "ease-in"; | ||
/* Not a pure module */ |