From 6aec6d050f27fc7bd8dc3bbb9e5ff2db281f107b Mon Sep 17 00:00:00 2001 From: DieMyst Date: Mon, 18 Mar 2019 18:31:06 +0300 Subject: [PATCH] fix array initialization --- assembly/dice.ts | 6 +++--- assembly/index.ts | 6 +++--- tests/assembly/roundtrip.spec.as.ts | 6 +----- tests/utils/helpers.ts | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/assembly/dice.ts b/assembly/dice.ts index 88616f0..5e1ba1e 100644 --- a/assembly/dice.ts +++ b/assembly/dice.ts @@ -12,7 +12,7 @@ const DICE_LINE_COUNT: u8 = 6; export class GameManager { registeredPlayers: u64 = 0; - playerIds: u64[] = new Array(PLAYERS_MAX_COUNT); + playerIds: u64[] = new Array(); playerBalance: Map = new Map(); encoder: JSONEncoder = new JSONEncoder(); @@ -33,7 +33,7 @@ export class GameManager { let response = new JoinResponse(this.registeredPlayers); - this.registeredPlayers += 1; + this.registeredPlayers = this.registeredPlayers + 1; return response.serialize(); } @@ -53,7 +53,7 @@ export class GameManager { let balance: u64 = this.playerBalance.get(playerId); if (betSize > balance) { - let error = new ErrorResponse(`Player hasn't enough money: player's current balance is ${balance.toString()} while the bet is ${betSize.toString()}`); + let error = new ErrorResponse("Player hasn't enough money: player's current balance is " + balance.toString() + " while the bet is " + betSize.toString()); return error.serialize(); } diff --git a/assembly/index.ts b/assembly/index.ts index f4506bf..2e8dd5b 100644 --- a/assembly/index.ts +++ b/assembly/index.ts @@ -1,6 +1,6 @@ -import "allocator/tlsf"; -//import "allocator/buddy"; -//import "allocator/arena"; +// import "allocator/tlsf"; +import "allocator/buddy"; +// import "allocator/arena"; import {handler} from "./game_handler"; diff --git a/tests/assembly/roundtrip.spec.as.ts b/tests/assembly/roundtrip.spec.as.ts index 61b3a4e..e7735bc 100644 --- a/tests/assembly/roundtrip.spec.as.ts +++ b/tests/assembly/roundtrip.spec.as.ts @@ -1,4 +1,4 @@ -import "allocator/arena"; +import "allocator/buddy"; import { invoke } from "../../assembly/index"; @@ -26,15 +26,11 @@ export class SomeTest { for (let i = 3; i >= 0; i--) { let b = load(resultPtr + i) as i32; - logF64(b); resultLength = resultLength + b << i * 8; } - logF64(resultLength); logStr("result: " + String.fromUTF8(resultPtr + 4, resultLength)); - - return true; } } diff --git a/tests/utils/helpers.ts b/tests/utils/helpers.ts index b581be7..c31ff43 100644 --- a/tests/utils/helpers.ts +++ b/tests/utils/helpers.ts @@ -31,7 +31,7 @@ export async function setup(testFileName: string): Promise { if (!WebAssembly.validate(file)) { throw new Error(`WebAssembly binary "${ pathName }" file not valid!`); } - const imports = buildImports(`${ testFileName }.spec.as`, new WebAssembly.Memory({ initial: 2 })); + const imports = buildImports(`${ testFileName }.spec.as`, new WebAssembly.Memory({ initial: 200, maximum: 1000 })); const result = await WebAssembly.instantiate(file, imports); return demangle(result.instance.exports); }