Comments (3)
@btruhand Yes... this is a good point, and a decision I had a bit of trouble with.
The problem, is here and here. In order to loop-protect the code, I was stuck in a situation where basically I have to eval
the code twice. I also made a note about this here.
You would think that I'd be able to get rid of the surrounding if
block add the loop-protect transform directly right here, without having the intermediate function wontTimeout
which eval
s the code first to check for infinite loops (and silences the console), like this:
import wontTimeout, { loopProtect } from './loop-protect'
// ... other code from eval-code-run-tests.js
// if (wontTimeout(code)) {
try {
eval(
loopProtect(code) +
tail +
tests +
executeTests
)
} catch (e) {
console.log(e.toString())
}
// }
However, when I did this (my first try), it would work correctly when an infinite-loop was detected, but when there was no loop in the user's code, it would cause some very strange behavior which I was totally unable to explain (basically the test-runner would think that there was 1000s tests, and it would loop over those tests and log them all as failing, basically creating an infinite loop that didn't exist!).
So... I silenced the console in the first eval to prevent everything from being logged twice. I suppose I could do some kind of regexp test to check for the presence of loops and only transform the code if they exist, but I haven't tested this. I do see how silencing the console could be a disadvantage though.
from cs-playground-react.
Oh, and this should only be for infinite loops, when other errors are caught, it should still log any messages prior to the error stopping exection of the code
from cs-playground-react.
☝️@btruhand this PR fixes things, but it's a bit of a hack! Also removes another hack, so I guess it all evens out 😕
from cs-playground-react.
Related Issues (20)
- Fix "Flatten An Array" tests
- Add infinite loop protection
- cursor does not have enough contrast on light themes
- fix loop-protect bug
- Add theme class to sidebar--menu--sub-header HOT 8
- add reverse vowels challenge
- fix loop-protect issue, change timeout length HOT 4
- [staging]: add user created repls HOT 2
- [staging]: add repl share feature & address ls overwrite problem
- track menu state HOT 4
- future feature: searchable menu
- future feature: settings menu
- add flow for static type checking
- add modal for move to forced https warning
- [future feature] add "save / share all state" feature
- add hamburger menu and keybindings modal HOT 9
- BST algo remove has small glitch HOT 6
- Add transition to dropdowns HOT 1
- Benchmark for native sort() flawed? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cs-playground-react.