Skip to content

Commit

Permalink
Fixed issues with new error set implementation (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
chung-leong committed Apr 8, 2024
1 parent 78b34c7 commit be4e71e
Show file tree
Hide file tree
Showing 9 changed files with 25,445 additions and 11,527 deletions.
602 changes: 304 additions & 298 deletions node-zigar-addon/src/addon.js.txt

Large diffs are not rendered by default.

Binary file modified node-zigar/test/sample-modules/node-zigar-addon/linux.x64.node
Binary file not shown.
Binary file not shown.
15,747 changes: 10,338 additions & 5,409 deletions zigar-compiler/dist/index.cjs

Large diffs are not rendered by default.

20,004 changes: 14,486 additions & 5,518 deletions zigar-compiler/dist/index.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ pub const NormalError = error{
OutOfMemory,
};

pub const CommonError = error{
OutOfMemory,
NoMoreBeer,
};

pub const PossibleError = NormalError || StrangeError;

pub var error_var = NormalError.FileNotFound;
Expand Down
10 changes: 6 additions & 4 deletions zigar-compiler/test/integration/type-handling/error-set/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ export function addTests(importModule, options) {
NormalError,
StrangeError,
PossibleError,
CommonError,
print,
} = await importTest('as-static-variables');
expect(NormalError.OutOfMemory).to.be.instanceOf(Error);
expect(NormalError.OutOfMemory).to.be.instanceOf(NormalError);
expect(PossibleError.OutOfMemory).to.be.instanceOf(PossibleError);
expect(NormalError.OutOfMemory in NormalError).to.be.true;
expect(NormalError.OutOfMemory).to.equal(PossibleError.OutOfMemory);
expect(PossibleError.OutOfMemory in PossibleError).to.be.true;
expect(StrangeError.SystemIsOnFire).to.equal(PossibleError.SystemIsOnFire);
expect(StrangeError.SystemIsOnFire).to.be.instanceOf(PossibleError);
expect(() => StrangeError.SystemIsOnFire.$ = StrangeError.SystemIsOnFire).to.throw(TypeError);
expect(StrangeError.SystemIsOnFire in PossibleError).to.be.true;
expect(StrangeError.NoMoreBeer).to.equal(CommonError.NoMoreBeer);
expect(module.error_var).to.equal(NormalError.FileNotFound);
const [ before ] = await capture(() => print());
expect(before).to.equal('error.FileNotFound');
Expand Down
Loading

0 comments on commit be4e71e

Please sign in to comment.