-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Ensure legacy path.parts matches existing semantics (#1583)
The refactor in #1568 slightly changed the semantics of `path.parts` in that it didn't previously include `this` or the leading `@`. This commit restores the previous semantics.
- Loading branch information
1 parent
4f73b20
commit d051884
Showing
2 changed files
with
79 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { builders as b } from '@glimmer/syntax'; | ||
|
||
QUnit.module('[glimmer-syntax] AST nodes legacy interop'); | ||
|
||
QUnit.test('path.parts does not include this', (assert) => { | ||
let path = b.path('this.foo.bar'); | ||
|
||
assert.deepEqual(path.original, 'this.foo.bar', 'path.original should include this'); | ||
assert.deepEqual(path.head.type, 'ThisHead', 'path.head should be a ThisHead'); | ||
assert.deepEqual(path.parts, ['foo', 'bar'], 'path.parts should not include this'); | ||
|
||
path.parts = ['bar', 'baz']; | ||
|
||
assert.deepEqual(path.original, 'this.bar.baz', 'path.original should include this'); | ||
assert.deepEqual(path.head.type, 'ThisHead', 'path.head should be a ThisHead'); | ||
assert.deepEqual(path.parts, ['bar', 'baz'], 'path.parts should not include this'); | ||
|
||
path.head = b.head('@foo'); | ||
assert.deepEqual(path.head.type, 'AtHead', 'path.head should be a AtHead'); | ||
|
||
// Inconsistent, but we will allow it | ||
path.parts = ['this', 'foo', 'bar', 'baz']; | ||
|
||
assert.deepEqual(path.original, 'this.foo.bar.baz', 'path.original should include this'); | ||
assert.deepEqual(path.head.type, 'ThisHead', 'path.head should be a ThisHead'); | ||
assert.deepEqual(path.parts, ['foo', 'bar', 'baz'], 'path.parts should not include this'); | ||
}); | ||
|
||
QUnit.test('path.parts does not include @', (assert) => { | ||
let path = b.path('@foo.bar'); | ||
|
||
assert.deepEqual(path.original, '@foo.bar', 'path.original should include @'); | ||
assert.deepEqual(path.head.type, 'AtHead', 'path.head should be a AtHead'); | ||
assert.deepEqual(path.parts, ['foo', 'bar'], 'path.parts should not include @'); | ||
|
||
path.parts = ['bar', 'baz']; | ||
|
||
assert.deepEqual(path.original, '@bar.baz', 'path.original should include @'); | ||
assert.deepEqual(path.head.type, 'AtHead', 'path.head should be a AtHead'); | ||
assert.deepEqual(path.parts, ['bar', 'baz'], 'path.parts should not include @'); | ||
|
||
path.head = b.head('this'); | ||
assert.deepEqual(path.head.type, 'ThisHead', 'path.head should be a ThisHead'); | ||
|
||
// Inconsistent, but we will allow it | ||
path.parts = ['@foo', 'bar', 'baz']; | ||
|
||
assert.deepEqual(path.original, '@foo.bar.baz', 'path.original should include @'); | ||
assert.deepEqual(path.head.type, 'AtHead', 'path.head should be a AtHead'); | ||
assert.deepEqual(path.parts, ['foo', 'bar', 'baz'], 'path.parts should not include this'); | ||
}); |