| 47 | } |
| 48 | |
| 49 | function registerTest(test) { |
| 50 | if (!(test.precondition && !test.precondition())) { |
| 51 | var error; |
| 52 | try { |
| 53 | var res = test.test.call($this); |
| 54 | } catch(e) { |
| 55 | res = 'fail'; |
| 56 | error = e; |
| 57 | } |
| 58 | var retVal = /^s/i.test(test.id) |
| 59 | ? (res === true || typeof res == 'undefined' ? 'pass' : 'fail') |
| 60 | : (res === true ? 'pass' : 'fail'); |
| 61 | |
| 62 | if (retVal != 'pass') { |
| 63 | var precondition = (test.precondition !== undefined) |
| 64 | ? test.precondition.toString() |
| 65 | : ''; |
| 66 | |
| 67 | throw new Test262Error( |
| 68 | test.id, |
| 69 | test.path, |
| 70 | test.description, |
| 71 | test.test.toString(), |
| 72 | precondition, |
| 73 | retVal, |
| 74 | error); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | return { |
| 80 | registerTest: registerTest |