diff --git a/test/blackbox-tests/mel-as-in-external.t b/test/blackbox-tests/mel-as-in-external.t new file mode 100644 index 0000000000..00f1afbcb3 --- /dev/null +++ b/test/blackbox-tests/mel-as-in-external.t @@ -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 < (lang dune 3.8) + > (using melange 0.1) + > EOF + + $ cat > dune < (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 */