Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyProgrammist committed Jan 13, 2024
1 parent 24d5a35 commit 09c1907
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 7 deletions.
82 changes: 82 additions & 0 deletions test/generated_files/generated_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,20 @@ export interface GramsUser {
readonly g: bigint;
}

// a$_ x:(HashmapE 100 VarUIntegerUser) = HashmapVUIUser;

export interface HashmapVUIUser {
readonly kind: 'HashmapVUIUser';
readonly x: Dictionary<bigint, VarUIntegerUser>;
}

// a$_ x:(HashmapE 100 ^TypedParam) = HashmapTPCell;

export interface HashmapTPCell {
readonly kind: 'HashmapTPCell';
readonly x: Dictionary<bigint, TypedParam>;
}

// tmpa$_ a:# b:# = Simple;

export function loadSimple(slice: Slice): Simple {
Expand Down Expand Up @@ -2901,3 +2915,71 @@ export function storeGramsUser(gramsUser: GramsUser): (builder: Builder) => void

}

export function dictValue_hashmapVUIUser_x(): DictionaryValue<VarUIntegerUser> {
return {
serialize: ((arg: VarUIntegerUser, builder: Builder) => {
storeVarUIntegerUser(arg)(builder);
}),
parse: loadVarUIntegerUser,
}

}

// a$_ x:(HashmapE 100 VarUIntegerUser) = HashmapVUIUser;

export function loadHashmapVUIUser(slice: Slice): HashmapVUIUser {
let x: Dictionary<bigint, VarUIntegerUser> = Dictionary.load(Dictionary.Keys.BigUint(100), dictValue_hashmapVUIUser_x(), slice);
return {
kind: 'HashmapVUIUser',
x: x,
}

}

export function storeHashmapVUIUser(hashmapVUIUser: HashmapVUIUser): (builder: Builder) => void {
return ((builder: Builder) => {
builder.storeDict(hashmapVUIUser.x, Dictionary.Keys.BigUint(100), dictValue_hashmapVUIUser_x());
})

}

export function dictValue_hashmapTPCell_x(): DictionaryValue<TypedParam> {
return {
serialize: ((arg: TypedParam, builder: Builder) => {
((arg: TypedParam) => {
return ((builder: Builder) => {
let cell1 = beginCell();
storeTypedParam(arg)(cell1);
builder.storeRef(cell1);

})

})(arg)(builder);
}),
parse: ((slice: Slice) => {
let slice1 = slice.loadRef().beginParse();
return loadTypedParam(slice1)

}),
}

}

// a$_ x:(HashmapE 100 ^TypedParam) = HashmapTPCell;

export function loadHashmapTPCell(slice: Slice): HashmapTPCell {
let x: Dictionary<bigint, TypedParam> = Dictionary.load(Dictionary.Keys.BigUint(100), dictValue_hashmapTPCell_x(), slice);
return {
kind: 'HashmapTPCell',
x: x,
}

}

export function storeHashmapTPCell(hashmapTPCell: HashmapTPCell): (builder: Builder) => void {
return ((builder: Builder) => {
builder.storeDict(hashmapTPCell.x, Dictionary.Keys.BigUint(100), dictValue_hashmapTPCell_x());
})

}

5 changes: 4 additions & 1 deletion test/tlb/test.tlb
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,7 @@ a$_ v:(VarUInteger 5) = VarUIntegerUser;
a$_ v:(VarInteger 5) = VarIntegerUser;

nanograms$_ amount:(VarUInteger 16) = Grams;
a$_ g:Grams = GramsUser;
a$_ g:Grams = GramsUser;

a$_ x:(HashmapE 100 VarUIntegerUser) = HashmapVUIUser;
a$_ x:(HashmapE 100 ^TypedParam) = HashmapTPCell;
26 changes: 20 additions & 6 deletions test/tlbgen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Address, BitString, Cell, Dictionary, DictionaryKeyTypes, ExternalAddre
import { describe, expect, test } from '@jest/globals';
import { beginCell } from 'ton';
import { loadBlock, storeBlock } from './generated_files/generated_block';
import { AddressUser, AnonymousData, AnyAddressUser, BitLenArg, BitLenArgUser, BitSelection, BitUser, BoolUser, CellTypedField, CellsSimple, CheckCrc32, CheckKeyword, CombArgCellRefUser, ComplexTypedField, ConditionalField, ConditionalRef, ConstructorOrder, DollarTag, EmptyTag, EqualityExpression, ExprArgUser, ExtAddressUser, FalseAnonField, GramsUser, HashmapEUser, ImplicitCondition, IntBitsOutside, IntBitsParametrizedOutside, LessThan, LoadFromNegationOutsideExpr, ManyComb, MathExprAsCombArg, MultipleEmptyConstructor, NegationFromImplicit, ParamConst, ParamDifNames, ParamDifNamesUser, ParamNamedArgInSecondConstr, RefCombinatorAny, RefCombinatorInRef, SharpConstructor, SharpTag, Simple, True, TupleCheck, TwoConstructors, TypedField, TypedParam, Unary, UnaryUserCheckOrder, VarIntegerUser, VarUIntegerUser, loadAddressUser, loadAnonymousData, loadAnyAddressUser, loadBitLenArg, loadBitLenArgUser, loadBitSelection, loadBitUser, loadBoolUser, loadCellTypedField, loadCellsSimple, loadCheckCrc32, loadCheckKeyword, loadCombArgCellRefUser, loadComplexTypedField, loadConditionalField, loadConditionalRef, loadConstructorOrder, loadDollarTag, loadEmptyTag, loadEqualityExpression, loadExprArgUser, loadExtAddressUser, loadFalseAnonField, loadGramsUser, loadHashmapEUser, loadImplicitCondition, loadIntBitsOutside, loadIntBitsParametrizedOutside, loadLessThan, loadLoadFromNegationOutsideExpr, loadManyComb, loadMathExprAsCombArg, loadMultipleEmptyConstructor, loadNegationFromImplicit, loadParamConst, loadParamDifNames, loadParamDifNamesUser, loadParamNamedArgInSecondConstr, loadRefCombinatorAny, loadRefCombinatorInRef, loadSharpConstructor, loadSharpTag, loadSimple, loadTrue, loadTupleCheck, loadTwoConstructors, loadTypedField, loadTypedParam, loadUnary, loadUnaryUserCheckOrder, loadVarIntegerUser, loadVarUIntegerUser, storeAddressUser, storeAnonymousData, storeAnyAddressUser, storeBitLenArg, storeBitLenArgUser, storeBitSelection, storeBitUser, storeBoolUser, storeCellTypedField, storeCellsSimple, storeCheckCrc32, storeCheckKeyword, storeCombArgCellRefUser, storeComplexTypedField, storeConditionalField, storeConditionalRef, storeConstructorOrder, storeDollarTag, storeEmptyTag, storeEqualityExpression, storeExprArgUser, storeExtAddressUser, storeFalseAnonField, storeGramsUser, storeHashmapEUser, storeImplicitCondition, storeIntBitsOutside, storeIntBitsParametrizedOutside, storeLessThan, storeLoadFromNegationOutsideExpr, storeManyComb, storeMathExprAsCombArg, storeMultipleEmptyConstructor, storeNegationFromImplicit, storeParamConst, storeParamDifNames, storeParamDifNamesUser, storeParamNamedArgInSecondConstr, storeRefCombinatorAny, storeRefCombinatorInRef, storeSharpConstructor, storeSharpTag, storeSimple, storeTrue, storeTupleCheck, storeTwoConstructors, storeTypedField, storeTypedParam, storeUnary, storeUnaryUserCheckOrder, storeVarIntegerUser, storeVarUIntegerUser } from './generated_files/generated_test';
import { AddressUser, AnonymousData, AnyAddressUser, BitLenArg, BitLenArgUser, BitSelection, BitUser, BoolUser, CellTypedField, CellsSimple, CheckCrc32, CheckKeyword, CombArgCellRefUser, ComplexTypedField, ConditionalField, ConditionalRef, ConstructorOrder, DollarTag, EmptyTag, EqualityExpression, ExprArgUser, ExtAddressUser, FalseAnonField, GramsUser, HashmapEUser, HashmapTPCell, HashmapVUIUser, ImplicitCondition, IntBitsOutside, IntBitsParametrizedOutside, LessThan, LoadFromNegationOutsideExpr, ManyComb, MathExprAsCombArg, MultipleEmptyConstructor, NegationFromImplicit, ParamConst, ParamDifNames, ParamDifNamesUser, ParamNamedArgInSecondConstr, RefCombinatorAny, RefCombinatorInRef, SharpConstructor, SharpTag, Simple, True, TupleCheck, TwoConstructors, TypedField, TypedParam, Unary, UnaryUserCheckOrder, VarIntegerUser, VarUIntegerUser, loadAddressUser, loadAnonymousData, loadAnyAddressUser, loadBitLenArg, loadBitLenArgUser, loadBitSelection, loadBitUser, loadBoolUser, loadCellTypedField, loadCellsSimple, loadCheckCrc32, loadCheckKeyword, loadCombArgCellRefUser, loadComplexTypedField, loadConditionalField, loadConditionalRef, loadConstructorOrder, loadDollarTag, loadEmptyTag, loadEqualityExpression, loadExprArgUser, loadExtAddressUser, loadFalseAnonField, loadGramsUser, loadHashmapEUser, loadHashmapTPCell, loadHashmapVUIUser, loadImplicitCondition, loadIntBitsOutside, loadIntBitsParametrizedOutside, loadLessThan, loadLoadFromNegationOutsideExpr, loadManyComb, loadMathExprAsCombArg, loadMultipleEmptyConstructor, loadNegationFromImplicit, loadParamConst, loadParamDifNames, loadParamDifNamesUser, loadParamNamedArgInSecondConstr, loadRefCombinatorAny, loadRefCombinatorInRef, loadSharpConstructor, loadSharpTag, loadSimple, loadTrue, loadTupleCheck, loadTwoConstructors, loadTypedField, loadTypedParam, loadUnary, loadUnaryUserCheckOrder, loadVarIntegerUser, loadVarUIntegerUser, storeAddressUser, storeAnonymousData, storeAnyAddressUser, storeBitLenArg, storeBitLenArgUser, storeBitSelection, storeBitUser, storeBoolUser, storeCellTypedField, storeCellsSimple, storeCheckCrc32, storeCheckKeyword, storeCombArgCellRefUser, storeComplexTypedField, storeConditionalField, storeConditionalRef, storeConstructorOrder, storeDollarTag, storeEmptyTag, storeEqualityExpression, storeExprArgUser, storeExtAddressUser, storeFalseAnonField, storeGramsUser, storeHashmapEUser, storeHashmapTPCell, storeHashmapVUIUser, storeImplicitCondition, storeIntBitsOutside, storeIntBitsParametrizedOutside, storeLessThan, storeLoadFromNegationOutsideExpr, storeManyComb, storeMathExprAsCombArg, storeMultipleEmptyConstructor, storeNegationFromImplicit, storeParamConst, storeParamDifNames, storeParamDifNamesUser, storeParamNamedArgInSecondConstr, storeRefCombinatorAny, storeRefCombinatorInRef, storeSharpConstructor, storeSharpTag, storeSimple, storeTrue, storeTupleCheck, storeTwoConstructors, storeTypedField, storeTypedParam, storeUnary, storeUnaryUserCheckOrder, storeVarIntegerUser, storeVarUIntegerUser } from './generated_files/generated_test';
import { randomInt } from 'crypto';

const fixturesDir = path.resolve(__dirname, 'fixtures');
Expand Down Expand Up @@ -222,15 +222,29 @@ describe('Generating tlb code', () => {
let varIntegerUser: VarIntegerUser = { kind: 'VarIntegerUser', v: BigInt(-6) }
checkSameOnStoreLoad(varIntegerUser, loadVarIntegerUser, storeVarIntegerUser)

let x:Dictionary<number, number> = Dictionary.empty()
x.set(1, 6);
x.set(2, 7);
x.set(0, 5);
let simpleDict: Dictionary<number, number> = Dictionary.empty()
simpleDict.set(1, 6);
simpleDict.set(2, 7);
simpleDict.set(0, 5);
let hashmapEUser: HashmapEUser = {
kind: 'HashmapEUser',
x: x
x: simpleDict
}
checkSameOnStoreLoad(hashmapEUser, loadHashmapEUser, storeHashmapEUser);

let vuiDict: Dictionary<bigint, VarUIntegerUser> = Dictionary.empty()
vuiDict.set(BigInt(6), {kind: 'VarUIntegerUser', v: BigInt(5)})
vuiDict.set(BigInt(7), {kind: 'VarUIntegerUser', v: BigInt(3)})
let hashmapVUIUser: HashmapVUIUser = { kind: 'HashmapVUIUser', 'x': vuiDict}
checkSameOnStoreLoad(hashmapVUIUser, loadHashmapVUIUser, storeHashmapVUIUser);

let tpcDict: Dictionary<bigint, TypedParam> = Dictionary.empty()
tpcDict.set(BigInt(5), {kind: 'TypedParam', x: {kind: 'Maybe_just', value: {kind: 'SharpConstructor', c: 3, y: {kind: 'FixedIntParam', y: 4}}}})
tpcDict.set(BigInt(3), {kind: 'TypedParam', x: {kind: 'Maybe_just', value: {kind: 'SharpConstructor', c: 9, y: {kind: 'FixedIntParam', y: 8}}}})
let hashmapTPCell: HashmapTPCell = { kind: 'HashmapTPCell', x: tpcDict}
checkSameOnStoreLoad(hashmapTPCell, loadHashmapTPCell, storeHashmapTPCell);


})

test('Combinators', () => {
Expand Down

0 comments on commit 09c1907

Please sign in to comment.