Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
function unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eoussama committed Mar 17, 2024
1 parent 77370ba commit 0010425
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/functions.nkm
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ let me cook print(message) {
}

a sa7 hear me out retResult is multiply(2);
print("ret result: " + bait(2) + " * " + bait(multiplicator) + " = " + bait(retResult))
print("ret result: " + bait(2) + " * " + bait(multiplicator) + " = " + bait(retResult));
29 changes: 29 additions & 0 deletions test/functions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const Errno = require('../dist/langkama.umd.cjs').Errno;
const LangKama = require('../dist/langkama.umd.cjs').LangKama;
const LangKamaEvent = require('../dist/langkama.umd.cjs').LangKamaEvent;



describe('Functions', () => {
let compiler;

beforeEach(() => {
compiler = new LangKama();
});

test('Function definition', done => {
const code = `
let me cook add(a, b) {
reda a + b;
}
add(1, 2);
`;

compiler.on(LangKamaEvent.Success, result => {
expect(result.value).toBe(3);
done();
})
.interpret(code);
});
});

0 comments on commit 0010425

Please sign in to comment.