|
|
@@ -0,0 +1,47 @@
|
|
|
+"use strict";
|
|
|
+
|
|
|
+let assert = require("assert");
|
|
|
+let tests = require("./testdata.json");
|
|
|
+
|
|
|
+require("../../../../build/lib/parser/modellang");
|
|
|
+let Parser = modellangParser;
|
|
|
+
|
|
|
+let parseOpts = {locations: false, showAst: true};
|
|
|
+
|
|
|
+describe("Parser", function() {
|
|
|
+
|
|
|
+ describe("#parse()", function() {
|
|
|
+ Object.keys(tests).forEach(function(testName) {
|
|
|
+
|
|
|
+ describe(`for model ${testName}`, function() {
|
|
|
+ let test = tests[testName];
|
|
|
+ let actual = Parser.parse(test.input, {}, parseOpts);
|
|
|
+ let expected = test.expected;
|
|
|
+
|
|
|
+ it("should parse systems correctly", function() {
|
|
|
+ assert.deepEqual(actual.systems, expected.systems);
|
|
|
+ });
|
|
|
+
|
|
|
+ it("should parse behaviors correctly", function() {
|
|
|
+ assert.deepEqual(actual.behaviors, expected.behaviors);
|
|
|
+ });
|
|
|
+
|
|
|
+ it("should parse interactions correctly", function() {
|
|
|
+ assert.deepEqual(actual.interactions, expected.interactions);
|
|
|
+ });
|
|
|
+
|
|
|
+ it("should parse triggers correctly", function() {
|
|
|
+ assert.deepEqual(actual.triggers, expected.triggers);
|
|
|
+ });
|
|
|
+
|
|
|
+ it("should parse inits correctly", function() {
|
|
|
+ assert.deepEqual(actual.init, expected.init);
|
|
|
+ });
|
|
|
+
|
|
|
+ it("should parse ASTs correctly", function() {
|
|
|
+ assert.deepEqual(actual.ast, expected.ast);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+});
|