Skip to content

Commit

Permalink
address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-snezhko committed Jul 5, 2023
1 parent f4a38cf commit 62bb03c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
3 changes: 2 additions & 1 deletion compiler/test/grainfmt/includes.expected.gr
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ include "array"
include "array" as Foo
from List use { length, map, forEach as each }
from Opt use { MutableOpt, ImmutableOpt as Imm, type Opt, type Opt as OptAlias }
from Opt use { /* comment1 */ /* comment2 */ /* comment3 */ /* comment4 */ /* comment5 */ /* comment6 */ /* comment7 */ /* comment8 */
from Opt use { /* comment1 */ /* comment2 */ /* comment3 */ /* comment4 */ /* comment5 */ /* comment6 */ /* comment7 */ /* comment8 */ /* comment9 */
MutableOpt,
ImmutableOpt as Imm,
type Opt,
type Opt as OptAlias,
exception Exc as E,
exception Exc2,
}

include "runtime/unsafe/wasmi32"
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/grainfmt/includes.input.gr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ include /* special include */ "array"
include "array" as /* special include */ Foo
from List use { length, map, forEach as each }
from Opt use { MutableOpt, ImmutableOpt as Imm, type Opt, type Opt as OptAlias }
from Opt use { MutableOpt, /* comment1 */ ImmutableOpt /* comment2 */ as /* comment3 */ Imm /* comment4 */, /* comment5 */ type /* comment6 */ Opt, type Opt as /* comment7 */ OptAlias, exception Exc as /* comment8 */ E }
from Opt use { MutableOpt, /* comment1 */ ImmutableOpt /* comment2 */ as /* comment3 */ Imm /* comment4 */, /* comment5 */ type /* comment6 */ Opt, type Opt as /* comment7 */ OptAlias, exception Exc as /* comment8 */ E, exception Exc2 /* comment9 */ }

include "runtime/unsafe/wasmi32"
from WasmI32 use {
Expand Down
23 changes: 22 additions & 1 deletion compiler/test/suites/provides.re
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe("provides", ({test, testSkip}) => {
);
let assertCompileError = makeCompileErrorRunner(test);
let assertRunError = makeErrorRunner(test_or_skip);
let assertRun = makeRunner(test_or_skip);
let assertHasWasmExport = (name, prog, export) => {
test(
name,
Expand Down Expand Up @@ -154,7 +155,7 @@ describe("provides", ({test, testSkip}) => {
);
assertRunError(
"provide_exceptions1",
"include \"provideException\"; from ProvideException use *; let f = () => if (true) { throw MyException }; f()",
"include \"provideException\"; let f = () => if (true) { throw ProvideException.MyException }; f()",
"OriginalException",
);
assertRunError(
Expand All @@ -167,6 +168,26 @@ describe("provides", ({test, testSkip}) => {
"include \"reprovideException\"; from ReprovideException use { exception MyException as E }; let f = () => if (true) { throw E }; f()",
"OriginalException",
);
assertRun(
"provide_exceptions4",
{|
include "reprovideException"
from ReprovideException use { exception MyException, excVal1, excVal2 }
match (excVal1) {
MyException => print("good1"),
_ => assert false,
}
match (excVal2) {
MyException => print("good2"),
_ => assert false,
}
match (MyException) {
ReprovideException.MyException => print("good3"),
_ => assert false,
}
|},
"good1\ngood2\ngood3\n",
);

assertSnapshot("let_rec_provide", "provide let rec foo = () => 5");

Expand Down
4 changes: 3 additions & 1 deletion compiler/test/test-libs/provideException.gr
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ module ProvideException

exception OriginalException

provide { exception OriginalException as MyException }
let excVal1 = OriginalException

provide { exception OriginalException as MyException, excVal1 }
6 changes: 4 additions & 2 deletions compiler/test/test-libs/reprovideException.gr
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module ReprovideException

include "./provideException"
from ProvideException use { exception MyException }
from ProvideException use { exception MyException, excVal1 }

provide { exception MyException }
let excVal2 = ProvideException.MyException

provide { exception MyException, excVal1, excVal2 }

0 comments on commit 62bb03c

Please sign in to comment.