You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was testing my implementation of String.jack inside the folder StringTest which I uploaded to the Web IDE JackCompiler. The folder only consisted of the jack files: String.jack and Main.jack.
I noticed that whenever I printed a string, it would start with two whitespaces before printing any characters in the string., e.g. abc would become abc.
I did some debugging and I think the error is related to the following:
Since my folder did not include the Output.jack file, it retrieves the code from the built-in files. When printing a string (Output.printString()) there is a dependency to the function charAt inside String.jack. I assume the compiler does not reference my provided String.jack but instead the built-inString.jack which has a different implementation of the String object.
As a result, the behavior of how the string is getting printed is not deterministic and results into arbitrary characters being printed.
I then tested my custom String.jack with my custom Output.jack in the same StringTest directory and then my code would behave correctly.
I'm wondering now if it is possible to test the String.jack in isolation without providing your custom Output.jack file.
Additional Comments
No response
Do you want to try to fix this bug?
I want to try to add this feature!
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
This also affects MemoryTest even worse since it calls Array.new, which if there's no Array.hack in MemoryTest, will fall back to the built-in memory.ts functions, completely ignoring the memory code you were trying to test!
My PR re-writes the string and os functions to use pointers and heap like a real hack program would.
To fix the MemoryTest, the project files could use Memory.alloc instead of Array.new.
A more cohesive fix would probably be to have compiled golden VMs for each OS function instead of bespoke JS functions (although it might be slower)?
Tool
Jack Compiler
Interface
Website (https://nand2tetris.github.io/web-ide)
Contact Details
No response
What happened?
I was testing my implementation of
String.jack
inside the folderStringTest
which I uploaded to the Web IDE JackCompiler. The folder only consisted of the jack files:String.jack
andMain.jack
.I noticed that whenever I printed a string, it would start with two whitespaces before printing any characters in the string., e.g.
abc
would becomeabc
.I did some debugging and I think the error is related to the following:
Since my folder did not include the
Output.jack
file, it retrieves the code from the built-in files. When printing a string (Output.printString()
) there is a dependency to the functioncharAt
insideString.jack
. I assume the compiler does not reference my providedString.jack
but instead thebuilt-in
String.jack
which has a different implementation of the String object.As a result, the behavior of how the string is getting printed is not deterministic and results into arbitrary characters being printed.
I then tested my custom
String.jack
with my customOutput.jack
in the same StringTest directory and then my code would behave correctly.I'm wondering now if it is possible to test the String.jack in isolation without providing your custom
Output.jack
file.Additional Comments
No response
Do you want to try to fix this bug?
Code of Conduct
The text was updated successfully, but these errors were encountered: