-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
244 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { toNano } from "@ton/core"; | ||
import { ContractSystem } from "@tact-lang/emulator"; | ||
import { __DANGER_resetNodeId } from "../grammar/ast"; | ||
import { UnderscoreVariableTestContract } from "./features/output/underscore-variable_UnderscoreVariableTestContract"; | ||
|
||
describe("feature-underscore-variable", () => { | ||
beforeEach(() => { | ||
__DANGER_resetNodeId(); | ||
}); | ||
it("should implement underscore variables correctly", async () => { | ||
// Init | ||
const system = await ContractSystem.create(); | ||
const treasure = system.treasure("treasure"); | ||
const contract = system.open( | ||
await UnderscoreVariableTestContract.fromInit(), | ||
); | ||
await contract.send(treasure, { value: toNano("10") }, null); | ||
await system.run(); | ||
|
||
// Check methods | ||
expect(await contract.getTest1()).toEqual(0n); | ||
expect(await contract.getTest2()).toEqual(12n); | ||
expect(await contract.getTest3()).toEqual(6n); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
contract UnderscoreVariableTestContract { | ||
init() { | ||
// Nothing to do | ||
} | ||
|
||
receive() { | ||
// Nothing to do | ||
} | ||
|
||
get fun test1(): Int { | ||
try { | ||
nativeThrow(1); | ||
} catch (_) { | ||
return 0; | ||
} | ||
return 1; | ||
} | ||
|
||
get fun test2(): Int { | ||
let m: map<Int, Int> = emptyMap(); | ||
m.set(1, 2); | ||
m.set(2, 4); | ||
m.set(3, 6); | ||
let x: Int = 0; | ||
foreach (_, v in m) { | ||
x += v; | ||
} | ||
return x; | ||
} | ||
|
||
get fun test3(): Int { | ||
let m: map<Int, Int> = emptyMap(); | ||
m.set(1, 2); | ||
m.set(2, 4); | ||
m.set(3, 6); | ||
let x: Int = 0; | ||
foreach (k, _ in m) { | ||
x += k; | ||
} | ||
return x; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.