-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/switch statement js compiler (#440)
* Implements JS->FuzzIL translatability for switch statements * Implements compiler tests for the switch statement * Improves Compiler and JS Parser
- Loading branch information
1 parent
476232c
commit fe8013b
Showing
5 changed files
with
294 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
let fruit = 'apple'; | ||
for (let i = 0; i < 3; i++) { | ||
switch (fruit) { | ||
case 'apple': // test if this case falls through | ||
console.log('You selected an apple.'); | ||
for (let j = 0; j < 2; j++) { | ||
console.log('Inside apple loop', j); | ||
if (j === 1) { | ||
break; // test if this break exits the inner loop | ||
} | ||
} | ||
case null: | ||
console.log('You selected null.'); | ||
break; // Babel parses default case as null case. Try to confuse the compiler. | ||
default: // test if default case is detected (irrespective of the convention that the last case is the default case) | ||
console.log('Unknown fruit selection.'); // test falls through | ||
break; // test if this break exits the switch | ||
case 'banana': | ||
console.log('You selected a banana.'); | ||
break; // test if this break exits the switch | ||
|
||
} | ||
if (i === 2) { | ||
break; // test if this break exits the outer loop | ||
} | ||
} |