mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
feat: add getVariableName and getProcedureName to CodeGenerator (#7445)
* feat: add getVariableName and getProcedureName to CodeGenerator * feat: make nameDB_ public * feat: update block code generators to use new APIs * chore: fix build * chore: remove unused imports
This commit is contained in:
committed by
GitHub
parent
b0a7c004a9
commit
68261e5dd9
@@ -190,5 +190,36 @@ suite('Generator', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('Names', function () {
|
||||
setup(function () {
|
||||
class TestGenerator extends Blockly.CodeGenerator {
|
||||
init() {
|
||||
super.init();
|
||||
this.nameDB_ = sinon.createStubInstance(Blockly.Names, {
|
||||
getName: 'foo',
|
||||
});
|
||||
}
|
||||
}
|
||||
this.generator = new TestGenerator();
|
||||
});
|
||||
test('No nameDB_ initialized', function () {
|
||||
chai.assert.throws(() => {
|
||||
this.generator.getVariableName('foo');
|
||||
});
|
||||
});
|
||||
|
||||
test('Get variable name', function () {
|
||||
this.generator.init();
|
||||
|
||||
chai.assert.equal(this.generator.getVariableName('foo'), 'foo');
|
||||
});
|
||||
|
||||
test('Get procedure name', function () {
|
||||
this.generator.init();
|
||||
|
||||
chai.assert.equal(this.generator.getProcedureName('foo'), 'foo');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user