Skip to content

Commit 419580f

Browse files
committed
[BUGFIX beta] Fix async functions being treated as falsey
1 parent bdd219f commit 419580f

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

packages/@ember/-internals/glimmer/tests/utils/shared-conditional-tests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ const IfUnlessWithTestCases = [
402402
ObjectProxy.create({ content: true }),
403403
Object,
404404
function() {},
405+
async function() {},
405406
new String('hello'),
406407
new String(''),
407408
new Boolean(true),

packages/@ember/-internals/runtime/lib/type-of.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const TYPE_MAP = {
88
'[object Number]': 'number',
99
'[object String]': 'string',
1010
'[object Function]': 'function',
11+
'[object AsyncFunction]': 'function',
1112
'[object Array]': 'array',
1213
'[object Date]': 'date',
1314
'[object RegExp]': 'regexp',

packages/@ember/-internals/runtime/tests/core/is_array_test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ moduleFor(
1818
let length = { length: 12 };
1919
let strangeLength = { length: 'yes' };
2020
let fn = function() {};
21+
let asyncFn = async function() {};
2122
let arrayProxy = ArrayProxy.create({ content: emberA() });
2223

2324
assert.equal(isArray(numarray), true, '[1,2,3]');
@@ -29,6 +30,7 @@ moduleFor(
2930
assert.equal(isArray(strangeLength), false, '{ length: "yes" }');
3031
assert.equal(isArray(global), false, 'global');
3132
assert.equal(isArray(fn), false, 'function() {}');
33+
assert.equal(isArray(asyncFn), false, 'async function() {}');
3234
assert.equal(isArray(arrayProxy), true, '[]');
3335
}
3436

packages/@ember/-internals/runtime/tests/core/type_of_test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ moduleFor(
1717
let a = null;
1818
let arr = [1, 2, 3];
1919
let obj = {};
20-
let instance = EmberObject.create({ method() {} });
20+
let instance = EmberObject.create({
21+
method() {},
22+
async asyncMethod() {},
23+
});
2124

2225
assert.equal(typeOf(), 'undefined', 'undefined');
2326
assert.equal(typeOf(null), 'null', 'null');
@@ -36,6 +39,7 @@ moduleFor(
3639
assert.equal(typeOf(obj), 'object', 'item of type object');
3740
assert.equal(typeOf(instance), 'instance', 'item of type instance');
3841
assert.equal(typeOf(instance.method), 'function', 'item of type function');
42+
assert.equal(typeOf(instance.asyncMethod), 'function', 'item of type async function');
3943
assert.equal(typeOf(EmberObject.extend()), 'class', 'item of type class');
4044
assert.equal(typeOf(new Error()), 'error', 'item of type error');
4145
}

0 commit comments

Comments
 (0)