Skip to content

Commit

Permalink
add negative test case for implicit init feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Gusarich committed Mar 18, 2024
1 parent a16926d commit 7bf6af0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/test/feature-implicit-init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { toNano } from '@ton/core';
import { ContractSystem } from '@tact-lang/emulator';
import { __DANGER_resetNodeId } from '../grammar/ast';
import { MyContract } from './features/output/implicit-init_MyContract';
import { run } from '../node';

describe('feature-send', () => {
beforeEach(() => {
Expand Down Expand Up @@ -45,4 +46,12 @@ describe('feature-send', () => {
expect(await contract.getGetCounter()).toBe(2n);
expect(tracker.collect()).toMatchSnapshot();
});

it('should not compile with uninitialized storage fields', async () => {
const result = await run({
configPath: __dirname + '/test-tact.config.json',
projectNames: ['implicit-init-2'],
});
expect(result).toBe(false);
});
});
18 changes: 18 additions & 0 deletions src/test/features/implicit-init-2.tact
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import "@stdlib/deploy";

contract MyContract with Deployable {
counter: Int = 0;
test_field: Int;

receive("increment") {
self.counter += 1;
}

get fun getCounter(): Int {
return self.counter;
}

get fun getTestField(): Int {
return self.test_field;
}
}
12 changes: 12 additions & 0 deletions src/test/test-tact.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"projects": [
{
"name": "implicit-init-2",
"path": "./features/implicit-init-2.tact",
"output": "./features/output",
"options": {
"debug": true
}
}
]
}

0 comments on commit 7bf6af0

Please sign in to comment.