MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 21 lines 658 B view raw
1import { test, summary } from './helpers.js'; 2 3console.log('WeakRef Tests\n'); 4 5const obj1 = { name: 'test' }; 6const ref1 = new WeakRef(obj1); 7 8test('weakref deref returns target', ref1.deref() === obj1, true); 9test('weakref deref value', ref1.deref().name, 'test'); 10 11const obj2 = { value: 42 }; 12const ref2 = new WeakRef(obj2); 13test('weakref deref number value', ref2.deref().value, 42); 14 15const obj3 = {}; 16const ref3 = new WeakRef(obj3); 17test('weakref has deref method', typeof ref3.deref, 'function'); 18test('weakref instanceof', ref3 instanceof WeakRef, true); 19test('weakref prototype', Object.getPrototypeOf(ref3) === WeakRef.prototype, true); 20 21summary();