main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
874 bytes
|
Rev | Line | |
---|
[79a0317] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var test = require('tape');
|
---|
| 4 | var gPO = require('reflect.getprototypeof/polyfill')();
|
---|
| 5 | var gOPD = require('gopd');
|
---|
| 6 |
|
---|
| 7 | var hasProto = require('../');
|
---|
| 8 | var hasProtoAccessor = require('../accessor');
|
---|
| 9 |
|
---|
| 10 | var getter = require('dunder-proto/get');
|
---|
| 11 |
|
---|
| 12 | test('hasProtoAccessor', function (t) {
|
---|
| 13 | var result = hasProtoAccessor();
|
---|
| 14 | t.equal(typeof result, 'boolean', 'returns a boolean (' + result + ')');
|
---|
| 15 |
|
---|
| 16 | var obj = { __proto__: null };
|
---|
| 17 | if (result) {
|
---|
| 18 | t.notOk('toString' in obj, 'null object lacks toString');
|
---|
| 19 | t.equal(gPO(obj), null);
|
---|
| 20 | if (gOPD && getter) {
|
---|
| 21 | t.equal(getter(obj), null);
|
---|
| 22 | }
|
---|
| 23 | } else if (hasProto()) {
|
---|
| 24 | t.notOk('toString' in obj, 'null object lacks toString');
|
---|
| 25 | if (gOPD && getter) {
|
---|
| 26 | t.equal(getter(obj), null);
|
---|
| 27 | }
|
---|
| 28 | } else {
|
---|
| 29 | t.ok('toString' in obj, 'without proto, null object has toString');
|
---|
| 30 | t.equal(gPO(obj), Object.prototype);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | t.end();
|
---|
| 34 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.