Skip to content

Commit

Permalink
rename typeAnn to candidTypeObject
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Dec 5, 2023
1 parent 600a8f7 commit fa4a236
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export type ServiceMethodDefinition = {
};

type CandidMeta = {
typeAnnotation: string; // Either a type reference or type literal
candidTypeObject: string; // Either a type reference or type literal
typeAliasDeclarations: string[];
imports: Set<string>;
candidType: CandidType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type CandidValueAndMeta<T extends CorrespondingJSType, E = T> = {
agentArgumentValue: T;
agentResponseValue: E;
src: {
typeAnnotation: string;
candidTypeObject: string;
typeAliasDeclarations: string[];
imports: Set<string>;
valueLiteral: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export function CandidValueAndMetaArbGenerator<
).map(
([
{
candidMeta: { typeAnnotation, typeAliasDeclarations, imports }
candidMeta: { candidTypeObject, typeAliasDeclarations, imports }
},
{ agentArgumentValue, agentResponseValue, valueLiteral }
]) => {
return {
src: {
typeAnnotation,
candidTypeObject,
typeAliasDeclarations,
imports,
valueLiteral
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function _VecNat8DefinitionArb(): fc.Arbitrary<BlobCandidDefinition> {
const imports = new Set(['Vec', 'nat8']);
return {
candidMeta: {
typeAnnotation,
candidTypeObject: typeAnnotation,
typeAliasDeclarations,
imports,
candidType: 'blob'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function OptDefinitionArb(

return {
candidMeta: {
typeAnnotation,
candidTypeObject: typeAnnotation,
typeAliasDeclarations,
imports,
candidType: 'Opt'
Expand All @@ -54,7 +54,7 @@ function generateTypeAliasDeclarations(
}

function generateTypeAnnotation(innerType: CandidDefinition): string {
return `Opt(${innerType.candidMeta.typeAnnotation})`;
return `Opt(${innerType.candidMeta.candidTypeObject})`;
}

function generateImports(innerType: CandidDefinition): Set<string> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function RecordDefinitionArb(

return {
candidMeta: {
typeAnnotation,
candidTypeObject: typeAnnotation,
typeAliasDeclarations,
imports,
candidType: 'Record'
Expand All @@ -57,7 +57,7 @@ function generateTypeAnnotation(fields: Field[]): string {
return `Record({${fields
.map(
([fieldName, fieldDefinition]) =>
`${fieldName}: ${fieldDefinition.candidMeta.typeAnnotation}`
`${fieldName}: ${fieldDefinition.candidMeta.candidTypeObject}`
)
.join(',')}})`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function TupleDefinitionArb(

return {
candidMeta: {
typeAnnotation,
candidTypeObject: typeAnnotation,
typeAliasDeclarations,
imports,
candidType: 'Tuple'
Expand Down Expand Up @@ -60,7 +60,7 @@ function generateTypeAliasDeclarations(
}

function generateTypeAnnotation(fields: CandidDefinition[]) {
const innerTypes = fields.map((field) => field.candidMeta.typeAnnotation);
const innerTypes = fields.map((field) => field.candidMeta.candidTypeObject);

return `Tuple(${innerTypes.join(', ')})`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function VariantDefinitionArb(

return {
candidMeta: {
typeAnnotation,
candidTypeObject: typeAnnotation,
typeAliasDeclarations,
imports,
candidType: 'Variant'
Expand Down Expand Up @@ -82,7 +82,7 @@ function generateTypeAnnotation(fields: Field[]): string {
return `Variant({${fields
.map(
([fieldName, fieldDataType]) =>
`${fieldName}: ${fieldDataType.candidMeta.typeAnnotation}`
`${fieldName}: ${fieldDataType.candidMeta.candidTypeObject}`
)
.join(',')}})`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function VecDefinitionArb(

return {
candidMeta: {
typeAnnotation,
candidTypeObject: typeAnnotation,
typeAliasDeclarations,
imports,
candidType: 'Vec'
Expand Down Expand Up @@ -58,5 +58,5 @@ function generateImports(innerType: CandidDefinition): Set<string> {
}

function generateTypeAnnotation(innerType: CandidDefinition): string {
return `Vec(${innerType.candidMeta.typeAnnotation})`;
return `Vec(${innerType.candidMeta.candidTypeObject})`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function FuncDefinitionArb(

return {
candidMeta: {
typeAnnotation,
candidTypeObject: typeAnnotation,
typeAliasDeclarations,
imports,
candidType: 'Func'
Expand Down Expand Up @@ -97,7 +97,7 @@ function generateTypeAnnotation(
mode: Mode
): string {
const params = paramCandids
.map((param) => param.candidMeta.typeAnnotation)
.map((param) => param.candidMeta.candidTypeObject)
.join(', ');
return `Func([${params}], ${returnCandid.candidMeta.typeAnnotation}, '${mode}')`;
return `Func([${params}], ${returnCandid.candidMeta.candidTypeObject}, '${mode}')`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function ServiceDefinitionArb(
return {
name,
candidMeta: {
typeAnnotation,
candidTypeObject: typeAnnotation,
typeAliasDeclarations,
imports,
candidType: 'Service'
Expand All @@ -58,7 +58,7 @@ function ServiceMethodArb(
)
.map(([name, mode, params, returnType]): ServiceMethodDefinition => {
const paramCandidTypes = params.map(
(param) => param.candidMeta.typeAnnotation
(param) => param.candidMeta.candidTypeObject
);

const typeAliasDeclarations = params.reduce(
Expand All @@ -68,7 +68,7 @@ function ServiceMethodArb(
returnType.candidMeta.typeAliasDeclarations
);

const src = `${name}: ${mode}([${paramCandidTypes}], ${returnType.candidMeta.typeAnnotation})`;
const src = `${name}: ${mode}([${paramCandidTypes}], ${returnType.candidMeta.candidTypeObject})`;

const imports = params.reduce(
(acc, param) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function SimpleCandidDefinitionArb(
return fc
.tuple(UniqueIdentifierArb('typeDeclaration'), fc.boolean())
.map(([name, useTypeDeclaration]) => {
const typeAnnotation = useTypeDeclaration ? name : candidType;
const candidTypeObject = useTypeDeclaration ? name : candidType;
const imports = new Set([candidType]);
const typeAliasDeclarations = generateTypeAliasDeclarations(
name,
Expand All @@ -19,7 +19,7 @@ export function SimpleCandidDefinitionArb(
return {
candidMeta: {
candidType,
typeAnnotation,
candidTypeObject,
imports,
typeAliasDeclarations
}
Expand Down
4 changes: 2 additions & 2 deletions property_tests/arbitraries/query_method_arb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ function generateSourceCode<
callback: string
): string {
const paramCandidTypes = paramTypes
.map((param) => param.src.typeAnnotation)
.map((param) => param.src.candidTypeObject)
.join(', ');

const returnCandidType = returnType.src.typeAnnotation;
const returnCandidType = returnType.src.candidTypeObject;

return `${functionName}: query([${paramCandidTypes}], ${returnCandidType}, ${callback})`;
}
2 changes: 1 addition & 1 deletion property_tests/tests/func/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { generateTests } from './generate_tests';

const AllFuncsQueryMethod = QueryMethodArb(
fc.uniqueArray(FuncArb(), {
selector: (entry) => entry.src.typeAnnotation
selector: (entry) => entry.src.candidTypeObject
}),
FuncArb(),
{
Expand Down
2 changes: 1 addition & 1 deletion property_tests/tests/service/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { generateTests } from './generate_tests';

const AllServicesQueryMethod = QueryMethodArb(
fc.uniqueArray(ServiceArb(), {
selector: (entry) => entry.src.typeAnnotation
selector: (entry) => entry.src.candidTypeObject
}),
ServiceArb(),
{
Expand Down
2 changes: 1 addition & 1 deletion property_tests/tests/tuple/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { generateTests } from './generate_tests';

const AllTuplesQueryMethod = QueryMethodArb(
fc.uniqueArray(TupleArb(), {
selector: (entry) => entry.src.typeAnnotation
selector: (entry) => entry.src.candidTypeObject
}),
TupleArb(),
{
Expand Down
2 changes: 1 addition & 1 deletion property_tests/tests/variant/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { generateTests } from './generate_tests';

const AllVariantsQueryMethod = QueryMethodArb(
fc.uniqueArray(VariantArb(), {
selector: (entry) => entry.src.typeAnnotation
selector: (entry) => entry.src.candidTypeObject
}),
VariantArb(),
{
Expand Down

0 comments on commit fa4a236

Please sign in to comment.