Changeset 13861 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Apr 13, 2006, 3:33:16 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/testkjs.cpp
r13821 r13861 24 24 25 25 #include "config.h" 26 #include "collector.h" 26 27 27 28 #include "HashTraits.h" … … 35 36 #include <sys/time.h> 36 37 #endif 38 39 #include "protect.h" 37 40 38 41 #if PLATFORM(WIN_OS) … … 193 196 } 194 197 198 199 bool doIt(int argc, char** argv) 200 { 201 bool success = true; 202 GlobalImp* global = new GlobalImp(); 203 204 // create interpreter 205 Interpreter interp(global); 206 // add debug() function 207 global->put(interp.globalExec(), "debug", new TestFunctionImp(TestFunctionImp::Debug, 1)); 208 // add "print" for compatibility with the mozilla js shell 209 global->put(interp.globalExec(), "print", new TestFunctionImp(TestFunctionImp::Print, 1)); 210 // add "quit" for compatibility with the mozilla js shell 211 global->put(interp.globalExec(), "quit", new TestFunctionImp(TestFunctionImp::Quit, 0)); 212 // add "gc" for compatibility with the mozilla js shell 213 global->put(interp.globalExec(), "gc", new TestFunctionImp(TestFunctionImp::GC, 0)); 214 // add "version" for compatibility with the mozilla js shell 215 global->put(interp.globalExec(), "version", new TestFunctionImp(TestFunctionImp::Version, 1)); 216 global->put(interp.globalExec(), "run", new TestFunctionImp(TestFunctionImp::Run, 1)); 217 218 Interpreter::setShouldPrintExceptions(true); 219 220 for (int i = 1; i < argc; i++) { 221 const char* fileName = argv[i]; 222 if (strcmp(fileName, "-f") == 0) // mozilla test driver script uses "-f" prefix for files 223 continue; 224 225 char* script = createStringWithContentsOfFile(fileName); 226 if (!script) { 227 success = false; 228 break; // fail early so we can catch missing files 229 } 230 231 Completion completion = interp.evaluate(fileName, 0, script); 232 success = success && completion.complType() != Throw; 233 free(script); 234 } 235 236 return success; 237 } 238 239 195 240 int kjsmain(int argc, char** argv) 196 241 { … … 202 247 testIsInteger(); 203 248 204 bool success = true; 205 { 206 JSLock lock; 207 208 GlobalImp* global = new GlobalImp(); 209 210 // create interpreter 211 Interpreter interp(global); 212 // add debug() function 213 global->put(interp.globalExec(), "debug", new TestFunctionImp(TestFunctionImp::Debug, 1)); 214 // add "print" for compatibility with the mozilla js shell 215 global->put(interp.globalExec(), "print", new TestFunctionImp(TestFunctionImp::Print, 1)); 216 // add "quit" for compatibility with the mozilla js shell 217 global->put(interp.globalExec(), "quit", new TestFunctionImp(TestFunctionImp::Quit, 0)); 218 // add "gc" for compatibility with the mozilla js shell 219 global->put(interp.globalExec(), "gc", new TestFunctionImp(TestFunctionImp::GC, 0)); 220 // add "version" for compatibility with the mozilla js shell 221 global->put(interp.globalExec(), "version", new TestFunctionImp(TestFunctionImp::Version, 1)); 222 global->put(interp.globalExec(), "run", new TestFunctionImp(TestFunctionImp::Run, 1)); 223 224 Interpreter::setShouldPrintExceptions(true); 225 226 for (int i = 1; i < argc; i++) { 227 const char* fileName = argv[i]; 228 if (strcmp(fileName, "-f") == 0) // mozilla test driver script uses "-f" prefix for files 229 continue; 230 231 char* script = createStringWithContentsOfFile(fileName); 232 if (!script) { 233 success = false; 234 break; // fail early so we can catch missing files 235 } 236 237 Completion completion = interp.evaluate(fileName, 0, script); 238 success = success && completion.complType() != Throw; 239 free(script); 240 } 241 242 delete global; 243 } // end block, so that interpreter gets deleted 249 JSLock lock; 250 251 bool success = doIt(argc, argv); 252 253 #ifndef NDEBUG 254 Collector::collect(); 255 #endif 244 256 245 257 if (success)
Note:
See TracChangeset
for help on using the changeset viewer.