From 7bf6af0394cc15f590903730a8700202a54c5d42 Mon Sep 17 00:00:00 2001 From: Gusarich Date: Mon, 18 Mar 2024 03:09:12 +0300 Subject: [PATCH] add negative test case for implicit init feature --- src/test/feature-implicit-init.spec.ts | 9 +++++++++ src/test/features/implicit-init-2.tact | 18 ++++++++++++++++++ src/test/test-tact.config.json | 12 ++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 src/test/features/implicit-init-2.tact create mode 100644 src/test/test-tact.config.json diff --git a/src/test/feature-implicit-init.spec.ts b/src/test/feature-implicit-init.spec.ts index 6a67575e2..fb5af3af9 100644 --- a/src/test/feature-implicit-init.spec.ts +++ b/src/test/feature-implicit-init.spec.ts @@ -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(() => { @@ -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); + }); }); diff --git a/src/test/features/implicit-init-2.tact b/src/test/features/implicit-init-2.tact new file mode 100644 index 000000000..77e361784 --- /dev/null +++ b/src/test/features/implicit-init-2.tact @@ -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; + } +} \ No newline at end of file diff --git a/src/test/test-tact.config.json b/src/test/test-tact.config.json new file mode 100644 index 000000000..cbabf7f06 --- /dev/null +++ b/src/test/test-tact.config.json @@ -0,0 +1,12 @@ +{ + "projects": [ + { + "name": "implicit-init-2", + "path": "./features/implicit-init-2.tact", + "output": "./features/output", + "options": { + "debug": true + } + } + ] + } \ No newline at end of file