Skip to content

Commit

Permalink
turned throw error into assertion in reduce_computed_macros
Browse files Browse the repository at this point in the history
  • Loading branch information
bekzod committed Jun 26, 2017
1 parent bd96516 commit 97bd722
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
4 changes: 1 addition & 3 deletions packages/ember-glimmer/lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ class RootState {
let result = this.result = iteratorResult.value;

// override .render function after initial render
this.render = () => {
result.rerender(options);
};
this.render = () => result.rerender(options);
};
}

Expand Down
11 changes: 5 additions & 6 deletions packages/ember-runtime/lib/computed/reduce_computed_macros.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
*/

import { guidFor } from 'ember-utils';
import { assert, Error as EmberError } from 'ember-debug';
import { assert } from 'ember-debug';
import {
get,
ComputedProperty,
computed,
addObserver,
removeObserver,
isNone,
getProperties,
WeakMap
} from 'ember-metal';
Expand Down Expand Up @@ -573,9 +572,9 @@ export function intersect(...args) {
@public
*/
export function setDiff(setAProperty, setBProperty) {
if (arguments.length !== 2) {
throw new EmberError('setDiff requires exactly two dependent arrays.');
}
assert('Ember.computed.setDiff requires exactly two dependent arrays.',
arguments.length === 2
);

return computed(`${setAProperty}.[]`, `${setBProperty}.[]`, function() {
let setA = this.get(setAProperty);
Expand Down Expand Up @@ -620,7 +619,7 @@ export function collect(...dependentKeys) {
let res = emberA();
for (let key in properties) {
if (properties.hasOwnProperty(key)) {
if (isNone(properties[key])) {
if (properties[key] === undefined) {
res.push(null);
} else {
res.push(properties[key]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,25 +639,25 @@ QUnit.test('setDiff is readOnly', function() {
}, /Cannot set read-only property "diff" on object:/);
});

QUnit.test('it throws an error if given fewer or more than two dependent properties', function() {
throws(function () {
QUnit.test('it asserts if given fewer or more than two dependent properties', function() {
expectAssertion(function () {
EmberObject.extend({
diff: setDiff('array')
}).create({
array: emberA([1, 2, 3, 4, 5, 6, 7]),
array2: emberA([3, 4, 5])
});
}, /requires exactly two dependent arrays/, 'setDiff requires two dependent arrays');
}, /Ember\.computed\.setDiff requires exactly two dependent arrays/, 'setDiff requires two dependent arrays');

throws(function () {
expectAssertion(function () {
EmberObject.extend({
diff: setDiff('array', 'array2', 'array3')
}).create({
array: emberA([1, 2, 3, 4, 5, 6, 7]),
array2: emberA([3, 4, 5]),
array3: emberA([7])
});
}, /requires exactly two dependent arrays/, 'setDiff requires two dependent arrays');
}, /Ember\.computed\.setDiff requires exactly two dependent arrays/, 'setDiff requires two dependent arrays');
});


Expand Down

0 comments on commit 97bd722

Please sign in to comment.