Skip to content

Conversation

@Altanali
Copy link
Collaborator

@Altanali Altanali commented Aug 5, 2021

No description provided.

@Altanali Altanali requested a review from mdpratt August 5, 2021 22:07
@Altanali Altanali self-assigned this Aug 5, 2021
console.log("1. From Scratch\n" +
"2. From Text Diagram\n"
/*+ "3. From Table Transposed\n"*/);
selection = +prompt(mark);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afai understand this is converting the prompt result into a number ? This could be more explicit, it's not quickly obvious what that syntax does

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can use the Number() cast instead of +() cast to Number to clarity instead.



function prepareCircuit() {
let selection = NaN;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason it starts with NaN and not null/0 etc

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I only wanted to instantiate selection as some Falsey value.

test("Testing evaluateInput() with input 'help' and an empty circuit.", () => {
let expectedText = runner.printMenu();
runner.evaluateInput("help", circuit);
expect(console.log).toHaveBeenCalled();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant test

test("Testing evaluateInput() with input '-h' and an empty circuit.", () => {
let expectedText = runner.printMenu();
runner.evaluateInput("-h", circuit);
expect(console.log).toHaveBeenCalled();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

}
//
let registerIndices;
let re = /\[(\s*\d+\s*,{0,1}\s*)+\]/g;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this regex for?

Copy link
Collaborator Author

@Altanali Altanali Aug 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a regex that selects an array of integers from a string, i.e. any substring of the form "[integer1, integer2, integer3...]". I'll make the clear in a comment in the code.

break;
default:
let circuitBackup = circuit.clone();
let re = /((\w+-*)+\(\s*\d+\s*,\s*\[(\s*\d+\s*,{0,1}\s*)+\]\s*(,\s*\d+\.{0,1}\d*\s*)*\))/g;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs better naming

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. Will update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants