-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BaseNode.equals support, wip, needs more tests
This is basically a port of https://github.com/projectfluent/python-fluent/blob/90301381e9b4d56b317bd6f15adf38936569f023/fluent/syntax/ast.py#L76-L120
- Loading branch information
Showing
2 changed files
with
103 additions
and
0 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,30 @@ | ||
'use strict'; | ||
|
||
import assert from 'assert'; | ||
import * as AST from '../src/ast'; | ||
|
||
suite('BaseNode.equals', function() { | ||
test('Identifier.equals', function() { | ||
const thisNode = new AST.Identifier("name"); | ||
const otherNode = new AST.Identifier("name"); | ||
assert.strictEqual(thisNode.equals(otherNode), true); | ||
}); | ||
test('Node.type', function() { | ||
const thisNode = new AST.Identifier("name"); | ||
const otherNode = new AST.Function("name"); | ||
assert.strictEqual(thisNode.equals(otherNode), false); | ||
}); | ||
test('Array children', function() { | ||
const thisNode = new AST.Pattern([ | ||
new AST.TextElement("one"), | ||
new AST.TextElement("two"), | ||
new AST.TextElement("three"), | ||
]); | ||
let otherNode = new AST.Pattern([ | ||
new AST.TextElement("one"), | ||
new AST.TextElement("two"), | ||
new AST.TextElement("three"), | ||
]); | ||
assert.strictEqual(thisNode.equals(otherNode), true); | ||
}); | ||
}); |