Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
happytomatoe committed Oct 4, 2024
1 parent d67729e commit 375001d
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions simulator/src/jack/listener/validator.listener.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe("Jack validator listener", () => {
}`,
UndeclaredVariableError,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.b": genericSymbol(SubroutineType.Function, 1),
"Main.a": genericSymbol(SubroutineType.Function, 1),
},
Expand Down Expand Up @@ -468,7 +468,7 @@ describe("Jack validator listener", () => {
}`,
IncorrectParamsNumberInSubroutineCallError,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.a": genericSymbol(SubroutineType.Function, 2),
"Main.b": genericSymbol(SubroutineType.Function, 2),
},
Expand All @@ -494,7 +494,7 @@ describe("Jack validator listener", () => {
}`,
undefined,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.new": genericSymbol(SubroutineType.Constructor, 0),
"Main.a": genericSymbol(SubroutineType.Function, 0),
"Main.b": genericSymbol(SubroutineType.Method, 0),
Expand All @@ -515,7 +515,7 @@ describe("Jack validator listener", () => {
}`,
undefined,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.a": genericSymbol(SubroutineType.Method, 0),
"Main.b": genericSymbol(SubroutineType.Method, 0),
},
Expand All @@ -539,7 +539,7 @@ describe("Jack validator listener", () => {
}`,
MethodCalledAsFunctionError,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.b": genericSymbol(SubroutineType.Function, 0),
"Main.c": genericSymbol(SubroutineType.Method, 0),
},
Expand All @@ -559,7 +559,7 @@ describe("Jack validator listener", () => {
}`,
FunctionCalledAsMethodError,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.b": genericSymbol(SubroutineType.Function, 0),
"Main.c": genericSymbol(SubroutineType.Function, 0),
},
Expand All @@ -575,7 +575,7 @@ describe("Jack validator listener", () => {
}`,
IncorrectConstructorReturnType,
{
"Main": genericSymbol(),
Main: genericSymbol(),
D: genericSymbol(),
},
);
Expand All @@ -593,7 +593,7 @@ describe("Jack validator listener", () => {
}`,
UnreachableCodeError,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.new": genericSymbol(SubroutineType.Constructor, 0),
},
);
Expand All @@ -608,7 +608,7 @@ describe("Jack validator listener", () => {
}`,
ConstructorMushReturnThis,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.new": genericSymbol(SubroutineType.Constructor, 0),
},
);
Expand All @@ -625,7 +625,7 @@ describe("Jack validator listener", () => {
}`,
WrongLiteralTypeError,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.a": genericSymbol(SubroutineType.Function, 0),
String: genericSymbol(),
},
Expand All @@ -643,7 +643,7 @@ describe("Jack validator listener", () => {
}`,
WrongLiteralTypeError,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.a": genericSymbol(SubroutineType.Function, 0),
},
);
Expand All @@ -661,7 +661,7 @@ describe("Jack validator listener", () => {
}`,
WrongLiteralTypeError,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.a": genericSymbol(SubroutineType.Function, 0),
},
);
Expand All @@ -678,7 +678,7 @@ describe("Jack validator listener", () => {
}`,
IntLiteralOverflow,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.a": genericSymbol(SubroutineType.Function, 0),
},
);
Expand All @@ -695,7 +695,7 @@ describe("Jack validator listener", () => {
}`,
IntLiteralOverflow,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.a": genericSymbol(SubroutineType.Function, 0),
},
);
Expand All @@ -712,7 +712,7 @@ describe("Jack validator listener", () => {
}`,
FieldCantBeReferencedInFunction,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.a": genericSymbol(SubroutineType.Function, 0),
},
);
Expand All @@ -729,7 +729,7 @@ describe("Jack validator listener", () => {
}`,
undefined,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.a": genericSymbol(SubroutineType.Function, 0),
},
);
Expand All @@ -746,7 +746,7 @@ describe("Jack validator listener", () => {
}`,
ThisCantBeReferencedInFunction,
{
"Main": genericSymbol(),
Main: genericSymbol(),
"Main.a": genericSymbol(SubroutineType.Function, 0),
},
);
Expand Down Expand Up @@ -803,8 +803,8 @@ function testValidator<T extends { name: string }>(
} catch (e) {
throw new Error(
`Expected error ${expectedError.name} but got '` +
validator.errors.join(",") +
"'",
validator.errors.join(",") +
"'",
);
}
} else {
Expand All @@ -815,7 +815,6 @@ function testValidator<T extends { name: string }>(
}
}


/**
* TODO:
* Ideas for improvement -
Expand Down

0 comments on commit 375001d

Please sign in to comment.