Skip to content

Commit

Permalink
Merge pull request #1500 from demergent-labs/0_19_0_fixes
Browse files Browse the repository at this point in the history
0 19 0 fixes
  • Loading branch information
lastmjs authored Dec 13, 2023
2 parents 8ff7285 + 59d5dbd commit f4fdb8e
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/bitcoin/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const tests: Test[] = [
...impureSetup(wallets, state),
{
name: 'wait for blockchain balance to reflect',
wait: 60_000
wait: 120_000
},
...testCanisterFunctionality()
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export function Float32DefinitionArb(): fc.Arbitrary<FloatCandidDefinition> {
return SimpleCandidDefinitionArb('float32');
}

// TODO multiplying by zero is to remove -0
// TODO we should open an issue with agent-js
// TODO the agent should encode and decode -0 correctly
export function Float32ValueArb(): fc.Arbitrary<CandidValues<number>> {
return SimpleCandidValuesArb(fc.float(), floatToSrcLiteral);
return SimpleCandidValuesArb(
fc.float().map((sample) => (sample === 0 ? sample * 0 : sample)),
floatToSrcLiteral
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ export function Float64ValueArb(): fc.Arbitrary<CandidValues<number>> {
return SimpleCandidValuesArb(float64(), floatToSrcLiteral);
}

// TODO multiplying by zero is to remove -0
// TODO we should open an issue with agent-js
// TODO the agent should encode and decode -0 correctly
function float64(): fc.Arbitrary<number> {
return fc
.float64Array({ maxLength: 1, minLength: 1 })
.map((sample) => sample[0]);
.map((sample) => (sample[0] === 0 ? sample[0] * 0 : sample[0]));
}
55 changes: 54 additions & 1 deletion property_tests/arbitraries/js_function_name_arb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,60 @@ const azleKeywords = [
'Vec'
];

const jsKeywords = ['eval', 'var', 'new', 'try'];
const jsKeywords = [
'await',
'break',
'case',
'catch',
'class',
'const',
'continue',
'debugger',
'default',
'delete',
'do',
'else',
'enum',
'export',
'extends',
'false',
'finally',
'for',
'function',
'if',
'implements',
'import',
'in',
'instanceof',
'interface',
'let',
'new',
'null',
'package',
'private',
'protected',
'public',
'return',
'super',
'switch',
'static',
'this',
'throw',
'true',
'try',
'typeof',
'var',
'void',
'while',
'with',
'yield',
// Additional words with special meaning
'NaN',
'Infinity',
'undefined',
'arguments',
'eval'
];

export const JsFunctionNameArb = fc
.stringMatching(/^(_[a-zA-Z0-9]+|[a-zA-Z][a-zA-Z0-9]*)$/)
Expand Down
3 changes: 3 additions & 0 deletions src/compiler/generate_candid_and_canister_methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export function generateCandidAndCanisterMethods(mainJs: string): {

const sandbox = {
globalThis: {},
window: {},
self: {},
global: {},
crypto: {
getRandomValues: () => {
let array = new Uint8Array(32);
Expand Down

0 comments on commit f4fdb8e

Please sign in to comment.