Skip to content

Commit

Permalink
Merge pull request #19843 from mixonic/mixonic/dumb-assert
Browse files Browse the repository at this point in the history
  • Loading branch information
mixonic committed Nov 14, 2021
2 parents 017b11e + 43d3233 commit acdd8ea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
18 changes: 9 additions & 9 deletions packages/@ember/-internals/glimmer/lib/environment.ts
Expand Up @@ -66,6 +66,15 @@ setGlobalContext({
if (DEBUG) {
let { id } = options;

if (id === 'argument-less-helper-paren-less-invocation') {
throw new Error(
`A resolved helper cannot be passed as a named argument as the syntax is ` +
`ambiguously a pass-by-reference or invocation. Use the ` +
`\`{{helper 'foo-helper}}\` helper to pass by reference or explicitly ` +
`invoke the helper with parens: \`{{(fooHelper)}}\`.`
);
}

let override = VM_DEPRECATION_OVERRIDES.filter((o) => o.id === id)[0];

if (!override) throw new Error(`deprecation override for ${id} not found`);
Expand Down Expand Up @@ -98,15 +107,6 @@ const VM_DEPRECATION_OVERRIDES: (DeprecationOptions & {
disabled?: boolean;
message?: string;
})[] = [
{
id: 'argument-less-helper-paren-less-invocation',
url: 'https://deprecations.emberjs.com/v3.x#toc_argument-less-helper-paren-less-invocation',
until: '4.0.0',
for: 'ember-source',
since: {
enabled: '3.27.0',
},
},
{
id: 'setting-on-hash',
until: '4.4.0',
Expand Down
Expand Up @@ -870,25 +870,21 @@ if (DEBUG) {
this.registerHelper('is-string', ([value]) => typeof value === 'string');
}

['@test invoking an argument-less helper without parens in named argument position is deprecated']() {
['@test invoking an argument-less helper without parens in named argument position throws'](
assert
) {
this.registerHelper('foo', () => 'Hello, world!');

expectDeprecation(
assert.throws(
() => this.render('<Bar @content={{foo}} />', { foo: 'Not it!' }),
new RegExp(
/The `foo` helper was used in the `-top-level` template as /.source +
/`@content={{foo}}`\. This is ambigious between wanting the `@content` /.source +
/argument to be the `foo` helper itself, or the result of invoking the /.source +
/`foo` helper \(current behavior\)\. This implicit invocation behavior /.source +
/has been deprecated\./.source
)
`A resolved helper cannot be passed as a named argument as the syntax is ` +
`ambiguously a pass-by-reference or invocation. Use the ` +
`\`{{helper 'foo-helper}}\` helper to pass by reference or explicitly ` +
`invoke the helper with parens: \`{{(fooHelper)}}\`.`
);

this.assertText('[true][Hello, world!]');
this.assertStableRerender();
}

['@test invoking an argument-less helper with parens in named argument position is not deprecated']() {
['@test invoking an argument-less helper with parens in named argument position']() {
this.registerHelper('foo', () => 'Hello, world!');

expectNoDeprecation(() => this.render('<Bar @content={{(foo)}} />', { foo: 'Not it!' }));
Expand All @@ -897,7 +893,7 @@ if (DEBUG) {
this.assertStableRerender();
}

['@test invoking an argument-less helper with quotes in named argument position is not deprecated']() {
['@test invoking an argument-less helper with quotes in named argument position']() {
this.registerHelper('foo', () => 'Hello, world!');

expectNoDeprecation(() => this.render('<Bar @content="{{foo}}" />', { foo: 'Not it!' }));
Expand All @@ -906,7 +902,7 @@ if (DEBUG) {
this.assertStableRerender();
}

['@test passing a local helper in named argument position is not deprecated']() {
['@test passing a local helper in named argument position']() {
let foo = defineSimpleHelper(() => 'Hello, world!');

expectNoDeprecation(() =>
Expand All @@ -922,7 +918,7 @@ if (DEBUG) {
// is trying to call `block.compile()` but `block` is the reference for `this.foo`.
// So the execution stack is probably off-by-one or something.

['@test invoking a local helper with parens in named argument position is not deprecated']() {
['@test invoking a local helper with parens in named argument position']() {
let foo = defineSimpleHelper(() => 'Hello, world!');

expectNoDeprecation(() =>
Expand All @@ -933,9 +929,7 @@ if (DEBUG) {
this.assertStableRerender();
}

// TODO: this one doesn't work yet, and there is a failing test in glimmer-vm

['@skip invoking a helper with quotes in named argument position is not deprecated']() {
['@skip invoking a helper with quotes in named argument position']() {
let foo = defineSimpleHelper(() => 'Hello, world!');

expectNoDeprecation(() =>
Expand Down

0 comments on commit acdd8ea

Please sign in to comment.