-
-
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 tests showing behavior when externals have empty payload * fix externals with empty payloads in playground * add changelog entry
- Loading branch information
Showing
5 changed files
with
93 additions
and
8 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
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
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,11 @@ | ||
$ . ./setup.sh | ||
$ cat > x.ml <<EOF | ||
> external f : int = "" | ||
> EOF | ||
$ melc -ppx melppx x.ml | ||
File "x.ml", line 1, characters 0-21: | ||
1 | external f : int = "" | ||
^^^^^^^^^^^^^^^^^^^^^ | ||
Alert fragile: f : the external name is inferred from val name is unsafe from refactoring when changing value name | ||
// Generated by Melange | ||
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ |
17 changes: 17 additions & 0 deletions
17
test/blackbox-tests/melange-playground/compile-ml-external.t
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,17 @@ | ||
$ cat > input.js <<EOF | ||
> require(process.env.DUNE_SOURCEROOT + '/_build/default/bin/jsoo_main.bc.js'); | ||
> require(process.env.DUNE_SOURCEROOT + '/_build/default/bin/melange-cmijs.js'); | ||
> console.log(ocaml.compileML("external f : int = \"\"")); | ||
> EOF | ||
|
||
$ node input.js | ||
File "_none_", line 1, characters 0-21: | ||
Alert fragile: f : the external name is inferred from val name is unsafe from refactoring when changing value name | ||
{ | ||
js_code: '// Generated by Melange\n' + | ||
"/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */\n", | ||
warnings: [], | ||
type_hints: [ | ||
{ start: [Object], end: [Object], kind: 'core_type', hint: 'int' } | ||
] | ||
} |
52 changes: 52 additions & 0 deletions
52
test/blackbox-tests/melange-playground/compile-ml-mel-attr.t
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,52 @@ | ||
$ cat > input.js <<EOF | ||
> require(process.env.DUNE_SOURCEROOT + '/_build/default/bin/jsoo_main.bc.js'); | ||
> require(process.env.DUNE_SOURCEROOT + '/_build/default/bin/melange-cmijs.js'); | ||
> console.log(ocaml.compileML("external imul : int -> int -> int = \"imul\"[@@mel.scope \"Math\"]\nlet res = imul 1 2")); | ||
> EOF | ||
|
||
$ node input.js | ||
{ | ||
js_code: '// Generated by Melange\n' + | ||
'\n' + | ||
'\n' + | ||
'var res = Math.imul(1, 2);\n' + | ||
'\n' + | ||
'export {\n' + | ||
' res ,\n' + | ||
'}\n' + | ||
'/* res Not a pure module */\n', | ||
warnings: [], | ||
type_hints: [ | ||
{ start: [Object], end: [Object], kind: 'expression', hint: 'int' }, | ||
{ start: [Object], end: [Object], kind: 'expression', hint: 'int' }, | ||
{ | ||
start: [Object], | ||
end: [Object], | ||
kind: 'expression', | ||
hint: 'int -> int -> int' | ||
}, | ||
{ start: [Object], end: [Object], kind: 'expression', hint: 'int' }, | ||
{ | ||
start: [Object], | ||
end: [Object], | ||
kind: 'pattern_type', | ||
hint: 'int' | ||
}, | ||
{ start: [Object], end: [Object], kind: 'binding', hint: 'int' }, | ||
{ start: [Object], end: [Object], kind: 'core_type', hint: 'int' }, | ||
{ start: [Object], end: [Object], kind: 'core_type', hint: 'int' }, | ||
{ | ||
start: [Object], | ||
end: [Object], | ||
kind: 'core_type', | ||
hint: 'int -> int' | ||
}, | ||
{ start: [Object], end: [Object], kind: 'core_type', hint: 'int' }, | ||
{ | ||
start: [Object], | ||
end: [Object], | ||
kind: 'core_type', | ||
hint: 'int -> int -> int' | ||
} | ||
] | ||
} |