Skip to content

Commit

Permalink
Merge pull request #240 from peze/bump-2.1.2
Browse files Browse the repository at this point in the history
Bump 2.1.2
  • Loading branch information
peze authored Jan 6, 2025
2 parents 2496d04 + d197379 commit 7ee6a48
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@darabonba/parser",
"version": "2.1.1",
"version": "2.1.2",
"main": "index.js",
"directories": {
"lib": "lib",
Expand Down
3 changes: 1 addition & 2 deletions test/import.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ function callOSS(): string {
});

it('module instance should ok', function () {
const ast = readAndParse('fixtures/module_instance/main.dara');
console.log('%j', ast);
let ast = readAndParse('fixtures/module_instance/main.dara');
const [f1] = ast.moduleBody.nodes;
const [s1] = f1.functionBody.stmts.stmts;
expect(s1).to.be.eql({
Expand Down
39 changes: 39 additions & 0 deletions test/semantic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7642,5 +7642,44 @@ describe('semantic', function () {
'name': 'OSS'
}
});



ast = parse(`
model M {};
init() {
var a = 'abc';
a.split(',');
var m = new M;
m.validate();
return;
}`, '__filename');

const [, init] = ast.moduleBody.nodes;

const [, str, , model] = init.initBody.stmts;
expect(str.left.id).to.be.eql({
'tag': 2,
'loc': loc(5, 3, 5, 4),
'lexeme': 'a',
'index': 15,
'type': 'variable',
'moduleType': {
'type': 'basic',
'name': 'string'
}
});

expect(model.left.id).to.be.eql({
'tag': 2,
'loc': loc(7, 3, 7, 4),
'lexeme': 'm',
'index': 28,
'type': 'variable',
'moduleType': {
'type': 'model',
'name': 'M'
}
});
});
});

0 comments on commit 7ee6a48

Please sign in to comment.