Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: Testing StringTest with custom String.jack fails #542

Open
1 of 2 tasks
HofmT opened this issue Dec 24, 2024 · 0 comments
Open
1 of 2 tasks

[bug]: Testing StringTest with custom String.jack fails #542

HofmT opened this issue Dec 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@HofmT
Copy link

HofmT commented Dec 24, 2024

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 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-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 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
@HofmT HofmT added the bug Something isn't working label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant