Skip to content

Commit

Permalink
Add test for mel.as in mel.set external (#705)
Browse files Browse the repository at this point in the history
* add test for mel.as in mel.set external

* fix mel.as test
  • Loading branch information
jchavarri authored Aug 31, 2023
1 parent 9a9d304 commit c9809e1
Showing 1 changed file with 101 additions and 0 deletions.
101 changes: 101 additions & 0 deletions test/blackbox-tests/mel-as-in-external.t
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 */

0 comments on commit c9809e1

Please sign in to comment.