| OLD | NEW |
| 1 'use strict'; | 1 'use strict'; |
| 2 // This file already exists upstream. We are duplicating and updating it here. B
e sure to override the existing one |
| 3 // when upstreaming. |
| 2 | 4 |
| 3 self.getterRejects = (t, obj, getterName, target) => { | 5 self.getterRejects = (t, obj, getterName, target) => { |
| 4 const getter = Object.getOwnPropertyDescriptor(obj, getterName).get; | 6 const getter = Object.getOwnPropertyDescriptor(obj, getterName).get; |
| 5 | 7 |
| 6 return promise_rejects(t, new TypeError(), getter.call(target)); | 8 return promise_rejects(t, new TypeError(), getter.call(target)); |
| 7 }; | 9 }; |
| 8 | 10 |
| 9 self.methodRejects = (t, obj, methodName, target) => { | 11 self.methodRejects = (t, obj, methodName, target, args) => { |
| 10 const method = obj[methodName]; | 12 const method = obj[methodName]; |
| 11 | 13 |
| 12 return promise_rejects(t, new TypeError(), method.call(target)); | 14 return promise_rejects(t, new TypeError(), method.apply(target, args)); |
| 13 }; | 15 }; |
| 14 | 16 |
| 15 self.getterThrows = (obj, getterName, target) => { | 17 self.getterThrows = (obj, getterName, target) => { |
| 16 const getter = Object.getOwnPropertyDescriptor(obj, getterName).get; | 18 const getter = Object.getOwnPropertyDescriptor(obj, getterName).get; |
| 17 | 19 |
| 18 assert_throws(new TypeError(), () => getter.call(target), getterName + ' shoul
d throw a TypeError'); | 20 assert_throws(new TypeError(), () => getter.call(target), getterName + ' shoul
d throw a TypeError'); |
| 19 }; | 21 }; |
| 20 | 22 |
| 21 self.methodThrows = (obj, methodName, target, args) => { | 23 self.methodThrows = (obj, methodName, target, args) => { |
| 22 const method = obj[methodName]; | 24 const method = obj[methodName]; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 34 GCController.collect(); | 36 GCController.collect(); |
| 35 } else { | 37 } else { |
| 36 /* eslint-disable no-console */ | 38 /* eslint-disable no-console */ |
| 37 console.warn('Tests are running without the ability to do manual garbage col
lection. They will still work, but ' + | 39 console.warn('Tests are running without the ability to do manual garbage col
lection. They will still work, but ' + |
| 38 'coverage will be suboptimal.'); | 40 'coverage will be suboptimal.'); |
| 39 /* eslint-enable no-console */ | 41 /* eslint-enable no-console */ |
| 40 } | 42 } |
| 41 }; | 43 }; |
| 42 | 44 |
| 43 self.delay = ms => new Promise(resolve => step_timeout(resolve, ms)); | 45 self.delay = ms => new Promise(resolve => step_timeout(resolve, ms)); |
| 46 |
| 47 // For tests which verify that the implementation doesn't do something it should
n't, it's better not to use a |
| 48 // timeout. Instead, assume that any reasonable implementation is going to finis
h work after 2 times around the event |
| 49 // loop, and use flushAsyncEvents().then(() => assert_array_equals(...)); |
| 50 // Some tests include promise resolutions which may mean the test code takes a c
ouple of event loop visits itself. So go |
| 51 // around an extra 2 times to avoid complicating those tests. |
| 52 // TODO(ricea): Upstream this function to w3c repository. |
| 53 self.flushAsyncEvents = () => delay(0).then(() => delay(0)).then(() => delay(0))
.then(() => delay(0)); |
| OLD | NEW |