-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): fix wildcard import parsing, import hygiene (#504)
Signed-off-by: Matt Roberts <[email protected]>
- Loading branch information
Showing
8 changed files
with
214 additions
and
45 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
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
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 |
---|---|---|
|
@@ -263,6 +263,59 @@ describe('ModelFile', () => { | |
(() => modelFile2.validate()).should.not.throw(); | ||
}); | ||
|
||
it('should throw when attempting to import types from different versions of the same namespace', () => { | ||
const myModelManager = new ModelManager(); | ||
|
||
const freddo1 = `namespace [email protected] | ||
concept Chocolate {}`; | ||
|
||
const freddo2 = `namespace [email protected] | ||
concept Chocolate {}`; | ||
|
||
const acme = `namespace [email protected] | ||
import { Chocolate } from [email protected] | ||
import { Chocolate } from [email protected] | ||
`; | ||
|
||
let modelFile1 = ParserUtil.newModelFile(myModelManager, freddo1); | ||
myModelManager.addModelFile(modelFile1); | ||
|
||
let modelFile2 = ParserUtil.newModelFile(myModelManager, freddo2); | ||
myModelManager.addModelFile(modelFile2); | ||
|
||
let modelFile3 = ParserUtil.newModelFile(myModelManager, acme); | ||
|
||
(() => { | ||
modelFile3.validate(); | ||
}).should.throw('Importing types from different versions ("1.0.0", "2.0.0") of the same namespace "[email protected]" is not permitted.'); | ||
}); | ||
|
||
it('should throw when attempting to import types from unversioned and versioned versions of the same namespace', () => { | ||
const myModelManager = new ModelManager(); | ||
|
||
const freddo1 = `namespace org.freddos | ||
concept Chocolate {}`; | ||
|
||
const freddo2 = `namespace [email protected] | ||
concept Chocolate {}`; | ||
|
||
const acme = `namespace [email protected] | ||
import { Chocolate } from org.freddos | ||
import { Chocolate } from [email protected] | ||
`; | ||
|
||
let modelFile1 = ParserUtil.newModelFile(myModelManager, freddo1); | ||
myModelManager.addModelFile(modelFile1); | ||
|
||
let modelFile2 = ParserUtil.newModelFile(myModelManager, freddo2); | ||
myModelManager.addModelFile(modelFile2); | ||
|
||
let modelFile3 = ParserUtil.newModelFile(myModelManager, acme); | ||
|
||
(() => { | ||
modelFile3.validate(); | ||
}).should.throw('Importing types from different versions ("null", "2.0.0") of the same namespace "[email protected]" is not permitted.'); | ||
}); | ||
}); | ||
|
||
describe('#getDefinitions', () => { | ||
|
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
Oops, something went wrong.