mendixmodelsdk
Advanced tools
Comparing version 2.1.0-dev.d2d1402 to 2.1.0-dev.fa6cfed
[ | ||
{ | ||
"deltaType": "CREATE_UNIT", | ||
"unitId": "123bbc62-9942-4a04-aea3-6a65817a438f", | ||
"unitId": "1d329a5a-4a3e-49a0-8d31-dc83e1983203", | ||
"containerId": "eec3241d-13a9-4ba9-940c-5d5223624304", | ||
@@ -10,4 +10,4 @@ "containmentName": "modules", | ||
{ | ||
"unitId": "123bbc62-9942-4a04-aea3-6a65817a438f", | ||
"elementId": "123bbc62-9942-4a04-aea3-6a65817a438f", | ||
"unitId": "1d329a5a-4a3e-49a0-8d31-dc83e1983203", | ||
"elementId": "1d329a5a-4a3e-49a0-8d31-dc83e1983203", | ||
"deltaType": "UPDATE_PROPERTY_VALUE", | ||
@@ -22,4 +22,4 @@ "propertyName": "name", | ||
"deltaType": "CREATE_UNIT", | ||
"unitId": "24f35d4b-00bb-453d-8e15-fdc670fcfa2c", | ||
"containerId": "123bbc62-9942-4a04-aea3-6a65817a438f", | ||
"unitId": "1d218048-c130-403d-a10c-36b62653ce67", | ||
"containerId": "1d329a5a-4a3e-49a0-8d31-dc83e1983203", | ||
"containmentName": "domainModel", | ||
@@ -30,4 +30,4 @@ "contentType": "DomainModels$DomainModel" | ||
"deltaType": "CREATE_UNIT", | ||
"unitId": "28f7c76c-4092-40d0-bf60-e8bd1ed755e6", | ||
"containerId": "123bbc62-9942-4a04-aea3-6a65817a438f", | ||
"unitId": "4f5d255a-bd4e-46c6-822c-d44d2c55b09f", | ||
"containerId": "1d329a5a-4a3e-49a0-8d31-dc83e1983203", | ||
"containmentName": "folders", | ||
@@ -37,4 +37,4 @@ "contentType": "Projects$Folder" | ||
{ | ||
"unitId": "28f7c76c-4092-40d0-bf60-e8bd1ed755e6", | ||
"elementId": "28f7c76c-4092-40d0-bf60-e8bd1ed755e6", | ||
"unitId": "4f5d255a-bd4e-46c6-822c-d44d2c55b09f", | ||
"elementId": "4f5d255a-bd4e-46c6-822c-d44d2c55b09f", | ||
"deltaType": "UPDATE_PROPERTY_VALUE", | ||
@@ -49,4 +49,4 @@ "propertyName": "name", | ||
"deltaType": "CREATE_UNIT", | ||
"unitId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"containerId": "28f7c76c-4092-40d0-bf60-e8bd1ed755e6", | ||
"unitId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"containerId": "4f5d255a-bd4e-46c6-822c-d44d2c55b09f", | ||
"containmentName": "documents", | ||
@@ -56,4 +56,4 @@ "contentType": "Pages$Page" | ||
{ | ||
"unitId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"elementId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"unitId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"elementId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"deltaType": "UPDATE_PROPERTY_VALUE", | ||
@@ -67,4 +67,4 @@ "propertyName": "canvasWidth", | ||
{ | ||
"unitId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"elementId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"unitId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"elementId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"deltaType": "UPDATE_PROPERTY_VALUE", | ||
@@ -78,28 +78,28 @@ "propertyName": "canvasHeight", | ||
{ | ||
"parentId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"parentId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"elementType": "Pages$LayoutCall", | ||
"parentPropertyName": "layoutCall", | ||
"deltaType": "CREATE_ELEMENT", | ||
"unitId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"elementId": "35ee5df9-69d8-47e6-9af9-a19f439b620c" | ||
"unitId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"elementId": "1333a80b-64f1-4c85-924c-64e6c7d31b8f" | ||
}, | ||
{ | ||
"parentId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"parentId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"elementType": "Texts$Text", | ||
"parentPropertyName": "title", | ||
"deltaType": "CREATE_ELEMENT", | ||
"unitId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"elementId": "2dde803b-52b3-4d8e-916d-4700cbba6005" | ||
"unitId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"elementId": "018193f3-ee85-4599-8b92-6cbd7ef834c0" | ||
}, | ||
{ | ||
"parentId": "2dde803b-52b3-4d8e-916d-4700cbba6005", | ||
"parentId": "018193f3-ee85-4599-8b92-6cbd7ef834c0", | ||
"elementType": "Texts$Translation", | ||
"parentPropertyName": "translations", | ||
"deltaType": "CREATE_ELEMENT", | ||
"unitId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"elementId": "a4e61761-9476-4e3e-a1ae-8c21f62ebd53" | ||
"unitId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"elementId": "1681369a-c23f-4971-a5cf-092be4eab6a8" | ||
}, | ||
{ | ||
"unitId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"elementId": "a4e61761-9476-4e3e-a1ae-8c21f62ebd53", | ||
"unitId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"elementId": "1681369a-c23f-4971-a5cf-092be4eab6a8", | ||
"deltaType": "UPDATE_PROPERTY_VALUE", | ||
@@ -113,4 +113,4 @@ "propertyName": "languageCode", | ||
{ | ||
"unitId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"elementId": "a4e61761-9476-4e3e-a1ae-8c21f62ebd53", | ||
"unitId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"elementId": "1681369a-c23f-4971-a5cf-092be4eab6a8", | ||
"deltaType": "UPDATE_PROPERTY_VALUE", | ||
@@ -124,4 +124,4 @@ "propertyName": "text", | ||
{ | ||
"unitId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"elementId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"unitId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"elementId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"deltaType": "UPDATE_PROPERTY_VALUE", | ||
@@ -135,4 +135,4 @@ "propertyName": "popupResizable", | ||
{ | ||
"unitId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"elementId": "82b2bb1b-275e-4392-8c63-e589b0a0e11c", | ||
"unitId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"elementId": "1c16b34d-528c-4eb4-9e97-94fae4975110", | ||
"deltaType": "UPDATE_PROPERTY_VALUE", | ||
@@ -139,0 +139,0 @@ "propertyName": "name", |
@@ -10,2 +10,7 @@ import { IEObject } from '../sdk/checks/base-types'; | ||
} | ||
export interface MxBuiltInCallExpression extends MxFeatureCallExpression { | ||
variable: MxBuiltInVariableDeclaration; | ||
} | ||
export interface MxBuiltInVariableDeclaration extends MxNamed { | ||
} | ||
export interface MxColorLiteralExpression extends MxPrimitiveLiteralExpression { | ||
@@ -30,2 +35,5 @@ blue: number; | ||
} | ||
export interface MxFollow extends MxBuiltInCallExpression { | ||
path: MxExpression; | ||
} | ||
export interface MxIntegerLiteralExpression extends MxPrimitiveLiteralExpression { | ||
@@ -36,3 +44,3 @@ value: number; | ||
body: MxExpression; | ||
referredIterator: string; | ||
type: MxIteratorType; | ||
variable: MxIteratorVariableDeclaration; | ||
@@ -87,2 +95,9 @@ } | ||
} | ||
export interface MxSwitch extends MxBuiltInCallExpression { | ||
cases: MxSwitchCase[]; | ||
} | ||
export interface MxSwitchCase extends IEObject { | ||
condition: MxExpression; | ||
value: MxExpression; | ||
} | ||
export interface MxThisExpression extends MxExpression { | ||
@@ -108,3 +123,11 @@ } | ||
DEPRECATION = 3, | ||
TODO = 4, | ||
} | ||
export declare enum MxIteratorType { | ||
NONE = 0, | ||
MAP = 1, | ||
FILTER = 2, | ||
EVERY = 3, | ||
SOME = 4, | ||
} | ||
export declare enum MxOperator { | ||
@@ -120,3 +143,2 @@ NONE = 0, | ||
OR = 8, | ||
IMPLIES = 9, | ||
} | ||
@@ -123,0 +145,0 @@ export declare enum MxPrimitiveTypeEnum { |
@@ -6,4 +6,13 @@ (function (MxCheckSeverity) { | ||
MxCheckSeverity[MxCheckSeverity["DEPRECATION"] = 3] = "DEPRECATION"; | ||
MxCheckSeverity[MxCheckSeverity["TODO"] = 4] = "TODO"; | ||
})(exports.MxCheckSeverity || (exports.MxCheckSeverity = {})); | ||
var MxCheckSeverity = exports.MxCheckSeverity; | ||
(function (MxIteratorType) { | ||
MxIteratorType[MxIteratorType["NONE"] = 0] = "NONE"; | ||
MxIteratorType[MxIteratorType["MAP"] = 1] = "MAP"; | ||
MxIteratorType[MxIteratorType["FILTER"] = 2] = "FILTER"; | ||
MxIteratorType[MxIteratorType["EVERY"] = 3] = "EVERY"; | ||
MxIteratorType[MxIteratorType["SOME"] = 4] = "SOME"; | ||
})(exports.MxIteratorType || (exports.MxIteratorType = {})); | ||
var MxIteratorType = exports.MxIteratorType; | ||
(function (MxOperator) { | ||
@@ -19,3 +28,2 @@ MxOperator[MxOperator["NONE"] = 0] = "NONE"; | ||
MxOperator[MxOperator["OR"] = 8] = "OR"; | ||
MxOperator[MxOperator["IMPLIES"] = 9] = "IMPLIES"; | ||
})(exports.MxOperator || (exports.MxOperator = {})); | ||
@@ -22,0 +30,0 @@ var MxOperator = exports.MxOperator; |
@@ -1,4 +0,1 @@ | ||
var expressions = require('../../gen/expressions-meta-types'); | ||
var instances_1 = require('../../sdk/internal/instances'); | ||
var standard_library_1 = require("./standard-library"); | ||
var Closure = (function () { | ||
@@ -26,117 +23,149 @@ function Closure(parent, vars) { | ||
function evaluateExpr(expr, structure) { | ||
// share model across all helper functions (fall-backs are purely for testing...): | ||
var model = structure ? structure.model : undefined; | ||
var modelClasses = structure ? model._allModelClasses() : {}; | ||
return evalInt(expr, null, new Closure(null, {})); | ||
function letExpr(baseVariables, varName, expr, value) { | ||
return evalInt(expr, null, baseVariables.createNewClosure(varName, value)); | ||
} | ||
function evalInt(expr_, operand, variables) { | ||
var polyMap = { | ||
// for every non-abstract sub type of Evaluatable, provide an interpretation -- please sort by type name: | ||
"MxBinaryExpression": function (expr) { return evalBinary(expr, operand, variables); }, | ||
"MxBooleanLiteralExpression": function (expr) { return expr.value; }, | ||
"MxColorLiteralExpression": function (expr) { return { red: expr.red, green: expr.green, blue: expr.blue }; }, | ||
"MxDoubleLiteralExpression": function (expr) { return expr.value; }, | ||
"MxEnumLiteralExpression": function (expr) { | ||
throw new Error('cannot handle an expression of type MxEnumLiteralExpression: no enumeration specified'); | ||
}, | ||
"MxFeatureCallExpressionWrapper": function (expr) { | ||
var baseEval = evalInt(expr.featureCall, operand, variables); | ||
if (baseEval === undefined || expr.tail === null) | ||
return baseEval; | ||
return evalInt(expr.tail, baseEval, variables); | ||
}, | ||
"MxIntegerLiteralExpression": function (expr) { return expr.value; }, | ||
"MxIteratorCallExpression": function (expr) { | ||
var iterator = standard_library_1.StandardIterators[expr.referredIterator]; | ||
if (!iterator) | ||
throw new Error("Iterator not implemented: '" + expr.referredIterator + "'"); | ||
return iterator(operand, function (value) { return letExpr(variables, expr.variable.name, expr.body, value); }); | ||
}, | ||
"MxListLiteralExpression": function (expr) { | ||
var evalItems = expr.items.map(function (item) { return evalInt(item, operand, variables); }); | ||
return evalItems.some(function (evalItem) { return evalItem === undefined; }) ? undefined : evalItems; // simple failure semantics: propagate undefined | ||
}, | ||
"MxMethodCallExpression": function (expr) { | ||
var method = standard_library_1.StandardMethods[expr.referredMethod]; | ||
if (!method) | ||
throw new Error("Method not implemented by standard lib: " + expr.referredMethod); | ||
return method(operand, (expr.arguments || []).map(function (argExpr) { return evalInt(argExpr, operand, variables); })); | ||
}, | ||
"MxNavigationExpression": function (expr) { | ||
var baseEval = evalInt(expr.base, operand, variables); | ||
return (expr.tail === null || baseEval === undefined) | ||
? baseEval // simple failure semantics: propagate undefined | ||
: evalInt(expr.tail, baseEval, variables); | ||
}, | ||
"MxPrefixExpression": function (expr) { | ||
var exprEval = evalInt(expr.expression, operand, variables); | ||
return exprEval === undefined ? exprEval : (!exprEval); // simple failure semantics: propagate undefined | ||
}, | ||
"MxPropertyCallExpression": function (expr) { return operand === undefined ? undefined : operand[expr.referredProperty]; }, | ||
"MxQualifiedEnumLiteralExpression": function (expr) { return evalQualifiedEnumLiteral(expr); }, | ||
"MxSizeLiteralExpression": function (expr) { return { height: expr.height, width: expr.width }; }, | ||
"MxStringLiteralExpression": function (expr) { return expr.value; }, | ||
"MxStructureLiteralExpression": function (expr) { return evalStructureLiteral(expr, operand, variables); }, | ||
"MxThisExpression": function (expr) { return structure; }, | ||
"MxUndefinedExpression": function (expr) { return undefined; }, | ||
"MxVariableRefExpression": function (expr) { return variables.get(expr.referredVariable); } | ||
}; | ||
var evalFn = polyMap[expr_.$type]; | ||
if (!evalFn) | ||
throw new Error("unhandled expression type: " + expr_.$type); | ||
return evalFn(expr_); | ||
} | ||
function evalBinary(expr, operand, variables) { | ||
if (expr.operator === expressions.MxOperator.NONE) | ||
throw new Error('sentinel value of MxOperator not allowed in runtime'); | ||
var evalLeft = evalInt(expr.left, operand, variables); | ||
var evalRight = evalInt(expr.right, operand, variables); // (no shortcutting (yet?)) | ||
if (evalLeft === undefined || evalRight === undefined) { | ||
return undefined; // simple failure semantics: propagate undefined | ||
/** TODO: Enable again | ||
// share model across all helper functions (fall-backs are purely for testing...): | ||
const model = structure ? structure.model : undefined; | ||
const modelClasses = structure ? (model as AbstractModel)._allModelClasses() : {}; | ||
return evalInt(expr, null, new Closure(null, {})); | ||
function letExpr(baseVariables:Closure, varName:string, expr:Evaluatable, value:any) { | ||
return evalInt(expr, null, baseVariables.createNewClosure(varName, value)); | ||
} | ||
switch (expr.operator) { | ||
case expressions.MxOperator.AND: return evalLeft && evalRight; | ||
case expressions.MxOperator.EQUALS: return evalLeft === evalRight; | ||
case expressions.MxOperator.GREATER: return evalLeft > evalRight; // (no type coercion?) | ||
case expressions.MxOperator.GREATER_OR_EQUALS: return (evalLeft > evalRight) || (evalLeft === evalRight); // (some type coercion) | ||
case expressions.MxOperator.IMPLIES: return !evalLeft || evalRight; | ||
case expressions.MxOperator.LESS: return evalLeft < evalRight; // (no type coercion?) | ||
case expressions.MxOperator.LESS_OR_EQUALS: return (evalLeft < evalRight) || (evalLeft === evalRight); // (some type coercion) | ||
case expressions.MxOperator.OR: return evalLeft || evalRight; | ||
case expressions.MxOperator.UNEQUALS: return evalLeft !== evalRight; | ||
default: return undefined; | ||
function evalInt(expr_:Evaluatable, operand:any, variables:Closure):any { | ||
const polyMap:{ [typeName:string]:Evaluator } = { | ||
// for every non-abstract sub type of Evaluatable, provide an interpretation -- please sort by type name: | ||
"MxBinaryExpression": (expr:expressions.MxBinaryExpression) => evalBinary(expr, operand, variables), | ||
"MxBooleanLiteralExpression": (expr:expressions.MxBooleanLiteralExpression) => expr.value, | ||
"MxColorLiteralExpression": (expr:expressions.MxColorLiteralExpression) => { return { red: expr.red, green: expr.green, blue: expr.blue }; }, | ||
"MxDoubleLiteralExpression": (expr:expressions.MxDoubleLiteralExpression) => expr.value, | ||
"MxEnumLiteralExpression": (expr:expressions.MxEnumLiteralExpression) => { | ||
throw new Error('cannot handle an expression of type MxEnumLiteralExpression: no enumeration specified'); | ||
}, | ||
"MxFeatureCallExpressionWrapper": (expr:expressions.MxFeatureCallExpressionWrapper) => { | ||
const baseEval = evalInt(expr.featureCall, operand, variables); | ||
if (baseEval === undefined || expr.tail === null) | ||
return baseEval; | ||
return evalInt(expr.tail, baseEval, variables); | ||
}, | ||
"MxIntegerLiteralExpression": (expr:expressions.MxIntegerLiteralExpression) => expr.value, | ||
"MxIteratorCallExpression": (expr:expressions.MxIteratorCallExpression) => { | ||
const iterator = StandardIterators[expr.type]; | ||
if (!iterator) | ||
throw new Error(`Iterator not implemented: '${expr.type}'`); | ||
return iterator(operand, value => letExpr(variables, expr.variable.name, expr.body, value)); | ||
}, | ||
"MxListLiteralExpression": (expr:expressions.MxListLiteralExpression) => { | ||
const evalItems = expr.items.map(item => evalInt(item, operand, variables)); | ||
return evalItems.some(evalItem => evalItem === undefined) ? undefined : evalItems; // simple failure semantics: propagate undefined | ||
}, | ||
"MxMethodCallExpression": (expr:expressions.MxMethodCallExpression) => { | ||
const method = StandardMethods[expr.referredMethod]; | ||
if (!method) | ||
throw new Error(`Method not implemented by standard lib: ${expr.referredMethod}`); | ||
return method(operand, (expr.arguments || []).map(argExpr => evalInt(argExpr, operand, variables))); | ||
}, | ||
"MxNavigationExpression": (expr:expressions.MxNavigationExpression) => { | ||
const baseEval = evalInt(expr.base, operand, variables); | ||
return (expr.tail === null || baseEval === undefined) | ||
? baseEval // simple failure semantics: propagate undefined | ||
: evalInt(expr.tail, baseEval, variables); | ||
}, | ||
"MxPrefixExpression": (expr:expressions.MxPrefixExpression) => { | ||
const exprEval = evalInt(expr.expression, operand, variables); | ||
return exprEval === undefined ? exprEval : (!exprEval); // simple failure semantics: propagate undefined | ||
}, | ||
"MxPropertyCallExpression": (expr:expressions.MxPropertyCallExpression) => operand === undefined ? undefined : operand[expr.referredProperty], | ||
"MxQualifiedEnumLiteralExpression": (expr:expressions.MxQualifiedEnumLiteralExpression) => evalQualifiedEnumLiteral(expr), | ||
"MxSizeLiteralExpression": (expr:expressions.MxSizeLiteralExpression) => { return { height: expr.height, width: expr.width } }, | ||
"MxStringLiteralExpression": (expr:expressions.MxStringLiteralExpression) => expr.value, | ||
"MxStructureLiteralExpression": (expr:expressions.MxStructureLiteralExpression) => evalStructureLiteral(expr, operand, variables), | ||
"MxThisExpression": (expr:expressions.MxThisExpression) => structure, | ||
"MxUndefinedExpression": (expr:expressions.MxUndefinedExpression) => undefined, | ||
"MxVariableRefExpression": (expr:expressions.MxVariableRefExpression) => variables.get(expr.referredVariable) | ||
}; | ||
const evalFn = polyMap[expr_.$type]; | ||
if (!evalFn) | ||
throw new Error(`unhandled expression type: ${expr_.$type}`); | ||
return evalFn(expr_); | ||
} | ||
} | ||
function evalStructureLiteral(expr, operand, variables) { | ||
var assignments = {}; | ||
for (var _i = 0, _a = expr.assignments; _i < _a.length; _i++) { | ||
var assignment = _a[_i]; | ||
var evalAssignment = evalInt(assignment.value, operand, variables); | ||
if (evalAssignment === undefined) | ||
function evalBinary(expr:expressions.MxBinaryExpression, operand:any, variables: Closure): any { | ||
if (expr.operator === expressions.MxOperator.NONE) | ||
throw new Error('sentinel value of MxOperator not allowed in runtime'); | ||
const evalLeft = evalInt(expr.left, operand, variables); | ||
const evalRight = evalInt(expr.right, operand, variables); // (no shortcutting (yet?)) | ||
if (evalLeft === undefined || evalRight === undefined) { | ||
return undefined; // simple failure semantics: propagate undefined | ||
} | ||
switch (expr.operator) { | ||
case expressions.MxOperator.AND: return evalLeft && evalRight; | ||
case expressions.MxOperator.EQUALS: return evalLeft === evalRight; | ||
case expressions.MxOperator.GREATER: return evalLeft > evalRight; // (no type coercion?) | ||
case expressions.MxOperator.GREATER_OR_EQUALS: return (evalLeft > evalRight) || (evalLeft === evalRight); // (some type coercion) | ||
case expressions.MxOperator.LESS: return evalLeft < evalRight; // (no type coercion?) | ||
case expressions.MxOperator.LESS_OR_EQUALS: return (evalLeft < evalRight) || (evalLeft === evalRight); // (some type coercion) | ||
case expressions.MxOperator.OR: return evalLeft || evalRight; | ||
case expressions.MxOperator.UNEQUALS: return evalLeft !== evalRight; | ||
default: return undefined; | ||
} | ||
} | ||
function evalStructureLiteral(expr:expressions.MxStructureLiteralExpression, operand:any, variables:Closure):any { | ||
const assignments:{ [propertyName:string]:any } = {}; | ||
for (let assignment of expr.assignments) { | ||
const evalAssignment = evalInt(assignment.value, operand, variables); | ||
if (evalAssignment === undefined) | ||
return undefined; | ||
assignments[assignment.property] = evalAssignment; | ||
} | ||
const clazz = instancehelpers.lookupClass(expr.structure, modelClasses); | ||
if (!clazz) | ||
return undefined; | ||
assignments[assignment.property] = evalAssignment; | ||
const structure = clazz.create(model); | ||
if (!structure) | ||
return undefined; | ||
for (let propertyName in assignments) { | ||
structure['__' + propertyName].set(assignments[propertyName]); | ||
} | ||
return structure; | ||
} | ||
var clazz = instances_1.instancehelpers.lookupClass(expr.structure, modelClasses); | ||
if (!clazz) | ||
return undefined; | ||
var structure = clazz.create(model); | ||
if (!structure) | ||
return undefined; | ||
for (var propertyName in assignments) { | ||
structure['__' + propertyName].set(assignments[propertyName]); | ||
function evalQualifiedEnumLiteral(expr:expressions.MxQualifiedEnumLiteralExpression) { | ||
const enumClazz = instancehelpers.lookupClass(expr.enumeration, modelClasses); | ||
if (!enumClazz) | ||
return undefined; | ||
const literal = enumClazz[expr.literal]; | ||
if (!literal) | ||
return undefined; | ||
return literal; | ||
} | ||
return structure; | ||
} | ||
function evalQualifiedEnumLiteral(expr) { | ||
var enumClazz = instances_1.instancehelpers.lookupClass(expr.enumeration, modelClasses); | ||
if (!enumClazz) | ||
return undefined; | ||
var literal = enumClazz[expr.literal]; | ||
if (!literal) | ||
return undefined; | ||
return literal; | ||
} | ||
*/ | ||
} | ||
exports.evaluateExpr = evaluateExpr; |
@@ -1,2 +0,2 @@ | ||
/** Current SDK version: 2.1.0-dev.d2d1402 */ | ||
/** Current SDK version: 2.1.0-dev.fa6cfed */ | ||
export declare const SDK_VERSION: string; |
@@ -1,2 +0,2 @@ | ||
/** Current SDK version: 2.1.0-dev.d2d1402 */ | ||
/** Current SDK version: 2.1.0-dev.fa6cfed */ | ||
exports.SDK_VERSION = "2.1.0"; |
{ | ||
"name": "mendixmodelsdk", | ||
"version": "2.1.0-dev.d2d1402", | ||
"version": "2.1.0-dev.fa6cfed", | ||
"description": "Mendix Model SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# Release notes Mendix Model SDK | ||
## Next | ||
## 2.1.0 | ||
| story# | impact | description | | ||
|---|---|---| | ||
| 662135 | Minor | Added support for Mendix 6.4.0 | | ||
| 649171 / 623912 | Low | Working copies that are connected to sprintr projects can now be deployed and their runtime status can be requested | | ||
| 659702 | Low | Unit-loading now has an extra optional forceRefresh option. If set, it will then bypass the Mendix MOdel SDK cache, and get the fresh unit straight from the source/server. | ||
| 675290 | Minor | All classes that could be useful for reflection on the model are now exposed through `mendixmodelsdk`, so imports from `mendixmodelsdk/dist/sdk/internal/...` should no longer be needed. | | ||
| 675290 | Minor | Private members (starting with an underscore `_`) where not available in the docs but where available in the public typings and therefor in the IDE's. This has been fixed. It should not ever be necessary to ever access these members. But if you did access them, you now need to access the object to `any` first before the typechecker allows you to access these members | | ||
| 675290 | Minor | Private members (starting with an underscore `_`) where not available in the docs but where available in the public typings and therefor in the IDE's. This has been fixed. It should not ever be necessary to ever access these members. But if you did access them, you now need to access the object to `any` first before the typechecker allows you to access these members. The method `allProperties()` is now available on all structures for reflection purposes. | | ||
@@ -11,0 +13,0 @@ ## 2.0.0 |
@@ -10,2 +10,7 @@ import { IEObject } from '../sdk/checks/base-types'; | ||
} | ||
export interface MxBuiltInCallExpression extends MxFeatureCallExpression { | ||
variable: MxBuiltInVariableDeclaration; | ||
} | ||
export interface MxBuiltInVariableDeclaration extends MxNamed { | ||
} | ||
export interface MxColorLiteralExpression extends MxPrimitiveLiteralExpression { | ||
@@ -30,2 +35,5 @@ blue: number; | ||
} | ||
export interface MxFollow extends MxBuiltInCallExpression { | ||
path: MxExpression; | ||
} | ||
export interface MxIntegerLiteralExpression extends MxPrimitiveLiteralExpression { | ||
@@ -36,3 +44,3 @@ value: number; | ||
body: MxExpression; | ||
referredIterator: string; | ||
type: MxIteratorType; | ||
variable: MxIteratorVariableDeclaration; | ||
@@ -87,2 +95,9 @@ } | ||
} | ||
export interface MxSwitch extends MxBuiltInCallExpression { | ||
cases: MxSwitchCase[]; | ||
} | ||
export interface MxSwitchCase extends IEObject { | ||
condition: MxExpression; | ||
value: MxExpression; | ||
} | ||
export interface MxThisExpression extends MxExpression { | ||
@@ -108,3 +123,11 @@ } | ||
DEPRECATION = 3, | ||
TODO = 4, | ||
} | ||
export declare enum MxIteratorType { | ||
NONE = 0, | ||
MAP = 1, | ||
FILTER = 2, | ||
EVERY = 3, | ||
SOME = 4, | ||
} | ||
export declare enum MxOperator { | ||
@@ -120,3 +143,2 @@ NONE = 0, | ||
OR = 8, | ||
IMPLIES = 9, | ||
} | ||
@@ -123,0 +145,0 @@ export declare enum MxPrimitiveTypeEnum { |
@@ -6,4 +6,13 @@ (function (MxCheckSeverity) { | ||
MxCheckSeverity[MxCheckSeverity["DEPRECATION"] = 3] = "DEPRECATION"; | ||
MxCheckSeverity[MxCheckSeverity["TODO"] = 4] = "TODO"; | ||
})(exports.MxCheckSeverity || (exports.MxCheckSeverity = {})); | ||
var MxCheckSeverity = exports.MxCheckSeverity; | ||
(function (MxIteratorType) { | ||
MxIteratorType[MxIteratorType["NONE"] = 0] = "NONE"; | ||
MxIteratorType[MxIteratorType["MAP"] = 1] = "MAP"; | ||
MxIteratorType[MxIteratorType["FILTER"] = 2] = "FILTER"; | ||
MxIteratorType[MxIteratorType["EVERY"] = 3] = "EVERY"; | ||
MxIteratorType[MxIteratorType["SOME"] = 4] = "SOME"; | ||
})(exports.MxIteratorType || (exports.MxIteratorType = {})); | ||
var MxIteratorType = exports.MxIteratorType; | ||
(function (MxOperator) { | ||
@@ -19,3 +28,2 @@ MxOperator[MxOperator["NONE"] = 0] = "NONE"; | ||
MxOperator[MxOperator["OR"] = 8] = "OR"; | ||
MxOperator[MxOperator["IMPLIES"] = 9] = "IMPLIES"; | ||
})(exports.MxOperator || (exports.MxOperator = {})); | ||
@@ -22,0 +30,0 @@ var MxOperator = exports.MxOperator; |
@@ -1,4 +0,1 @@ | ||
var expressions = require('../../gen/expressions-meta-types'); | ||
var instances_1 = require('../../sdk/internal/instances'); | ||
var standard_library_1 = require("./standard-library"); | ||
var Closure = (function () { | ||
@@ -26,117 +23,149 @@ function Closure(parent, vars) { | ||
function evaluateExpr(expr, structure) { | ||
// share model across all helper functions (fall-backs are purely for testing...): | ||
var model = structure ? structure.model : undefined; | ||
var modelClasses = structure ? model._allModelClasses() : {}; | ||
return evalInt(expr, null, new Closure(null, {})); | ||
function letExpr(baseVariables, varName, expr, value) { | ||
return evalInt(expr, null, baseVariables.createNewClosure(varName, value)); | ||
} | ||
function evalInt(expr_, operand, variables) { | ||
var polyMap = { | ||
// for every non-abstract sub type of Evaluatable, provide an interpretation -- please sort by type name: | ||
"MxBinaryExpression": function (expr) { return evalBinary(expr, operand, variables); }, | ||
"MxBooleanLiteralExpression": function (expr) { return expr.value; }, | ||
"MxColorLiteralExpression": function (expr) { return { red: expr.red, green: expr.green, blue: expr.blue }; }, | ||
"MxDoubleLiteralExpression": function (expr) { return expr.value; }, | ||
"MxEnumLiteralExpression": function (expr) { | ||
throw new Error('cannot handle an expression of type MxEnumLiteralExpression: no enumeration specified'); | ||
}, | ||
"MxFeatureCallExpressionWrapper": function (expr) { | ||
var baseEval = evalInt(expr.featureCall, operand, variables); | ||
if (baseEval === undefined || expr.tail === null) | ||
return baseEval; | ||
return evalInt(expr.tail, baseEval, variables); | ||
}, | ||
"MxIntegerLiteralExpression": function (expr) { return expr.value; }, | ||
"MxIteratorCallExpression": function (expr) { | ||
var iterator = standard_library_1.StandardIterators[expr.referredIterator]; | ||
if (!iterator) | ||
throw new Error("Iterator not implemented: '" + expr.referredIterator + "'"); | ||
return iterator(operand, function (value) { return letExpr(variables, expr.variable.name, expr.body, value); }); | ||
}, | ||
"MxListLiteralExpression": function (expr) { | ||
var evalItems = expr.items.map(function (item) { return evalInt(item, operand, variables); }); | ||
return evalItems.some(function (evalItem) { return evalItem === undefined; }) ? undefined : evalItems; // simple failure semantics: propagate undefined | ||
}, | ||
"MxMethodCallExpression": function (expr) { | ||
var method = standard_library_1.StandardMethods[expr.referredMethod]; | ||
if (!method) | ||
throw new Error("Method not implemented by standard lib: " + expr.referredMethod); | ||
return method(operand, (expr.arguments || []).map(function (argExpr) { return evalInt(argExpr, operand, variables); })); | ||
}, | ||
"MxNavigationExpression": function (expr) { | ||
var baseEval = evalInt(expr.base, operand, variables); | ||
return (expr.tail === null || baseEval === undefined) | ||
? baseEval // simple failure semantics: propagate undefined | ||
: evalInt(expr.tail, baseEval, variables); | ||
}, | ||
"MxPrefixExpression": function (expr) { | ||
var exprEval = evalInt(expr.expression, operand, variables); | ||
return exprEval === undefined ? exprEval : (!exprEval); // simple failure semantics: propagate undefined | ||
}, | ||
"MxPropertyCallExpression": function (expr) { return operand === undefined ? undefined : operand[expr.referredProperty]; }, | ||
"MxQualifiedEnumLiteralExpression": function (expr) { return evalQualifiedEnumLiteral(expr); }, | ||
"MxSizeLiteralExpression": function (expr) { return { height: expr.height, width: expr.width }; }, | ||
"MxStringLiteralExpression": function (expr) { return expr.value; }, | ||
"MxStructureLiteralExpression": function (expr) { return evalStructureLiteral(expr, operand, variables); }, | ||
"MxThisExpression": function (expr) { return structure; }, | ||
"MxUndefinedExpression": function (expr) { return undefined; }, | ||
"MxVariableRefExpression": function (expr) { return variables.get(expr.referredVariable); } | ||
}; | ||
var evalFn = polyMap[expr_.$type]; | ||
if (!evalFn) | ||
throw new Error("unhandled expression type: " + expr_.$type); | ||
return evalFn(expr_); | ||
} | ||
function evalBinary(expr, operand, variables) { | ||
if (expr.operator === expressions.MxOperator.NONE) | ||
throw new Error('sentinel value of MxOperator not allowed in runtime'); | ||
var evalLeft = evalInt(expr.left, operand, variables); | ||
var evalRight = evalInt(expr.right, operand, variables); // (no shortcutting (yet?)) | ||
if (evalLeft === undefined || evalRight === undefined) { | ||
return undefined; // simple failure semantics: propagate undefined | ||
/** TODO: Enable again | ||
// share model across all helper functions (fall-backs are purely for testing...): | ||
const model = structure ? structure.model : undefined; | ||
const modelClasses = structure ? (model as AbstractModel)._allModelClasses() : {}; | ||
return evalInt(expr, null, new Closure(null, {})); | ||
function letExpr(baseVariables:Closure, varName:string, expr:Evaluatable, value:any) { | ||
return evalInt(expr, null, baseVariables.createNewClosure(varName, value)); | ||
} | ||
switch (expr.operator) { | ||
case expressions.MxOperator.AND: return evalLeft && evalRight; | ||
case expressions.MxOperator.EQUALS: return evalLeft === evalRight; | ||
case expressions.MxOperator.GREATER: return evalLeft > evalRight; // (no type coercion?) | ||
case expressions.MxOperator.GREATER_OR_EQUALS: return (evalLeft > evalRight) || (evalLeft === evalRight); // (some type coercion) | ||
case expressions.MxOperator.IMPLIES: return !evalLeft || evalRight; | ||
case expressions.MxOperator.LESS: return evalLeft < evalRight; // (no type coercion?) | ||
case expressions.MxOperator.LESS_OR_EQUALS: return (evalLeft < evalRight) || (evalLeft === evalRight); // (some type coercion) | ||
case expressions.MxOperator.OR: return evalLeft || evalRight; | ||
case expressions.MxOperator.UNEQUALS: return evalLeft !== evalRight; | ||
default: return undefined; | ||
function evalInt(expr_:Evaluatable, operand:any, variables:Closure):any { | ||
const polyMap:{ [typeName:string]:Evaluator } = { | ||
// for every non-abstract sub type of Evaluatable, provide an interpretation -- please sort by type name: | ||
"MxBinaryExpression": (expr:expressions.MxBinaryExpression) => evalBinary(expr, operand, variables), | ||
"MxBooleanLiteralExpression": (expr:expressions.MxBooleanLiteralExpression) => expr.value, | ||
"MxColorLiteralExpression": (expr:expressions.MxColorLiteralExpression) => { return { red: expr.red, green: expr.green, blue: expr.blue }; }, | ||
"MxDoubleLiteralExpression": (expr:expressions.MxDoubleLiteralExpression) => expr.value, | ||
"MxEnumLiteralExpression": (expr:expressions.MxEnumLiteralExpression) => { | ||
throw new Error('cannot handle an expression of type MxEnumLiteralExpression: no enumeration specified'); | ||
}, | ||
"MxFeatureCallExpressionWrapper": (expr:expressions.MxFeatureCallExpressionWrapper) => { | ||
const baseEval = evalInt(expr.featureCall, operand, variables); | ||
if (baseEval === undefined || expr.tail === null) | ||
return baseEval; | ||
return evalInt(expr.tail, baseEval, variables); | ||
}, | ||
"MxIntegerLiteralExpression": (expr:expressions.MxIntegerLiteralExpression) => expr.value, | ||
"MxIteratorCallExpression": (expr:expressions.MxIteratorCallExpression) => { | ||
const iterator = StandardIterators[expr.type]; | ||
if (!iterator) | ||
throw new Error(`Iterator not implemented: '${expr.type}'`); | ||
return iterator(operand, value => letExpr(variables, expr.variable.name, expr.body, value)); | ||
}, | ||
"MxListLiteralExpression": (expr:expressions.MxListLiteralExpression) => { | ||
const evalItems = expr.items.map(item => evalInt(item, operand, variables)); | ||
return evalItems.some(evalItem => evalItem === undefined) ? undefined : evalItems; // simple failure semantics: propagate undefined | ||
}, | ||
"MxMethodCallExpression": (expr:expressions.MxMethodCallExpression) => { | ||
const method = StandardMethods[expr.referredMethod]; | ||
if (!method) | ||
throw new Error(`Method not implemented by standard lib: ${expr.referredMethod}`); | ||
return method(operand, (expr.arguments || []).map(argExpr => evalInt(argExpr, operand, variables))); | ||
}, | ||
"MxNavigationExpression": (expr:expressions.MxNavigationExpression) => { | ||
const baseEval = evalInt(expr.base, operand, variables); | ||
return (expr.tail === null || baseEval === undefined) | ||
? baseEval // simple failure semantics: propagate undefined | ||
: evalInt(expr.tail, baseEval, variables); | ||
}, | ||
"MxPrefixExpression": (expr:expressions.MxPrefixExpression) => { | ||
const exprEval = evalInt(expr.expression, operand, variables); | ||
return exprEval === undefined ? exprEval : (!exprEval); // simple failure semantics: propagate undefined | ||
}, | ||
"MxPropertyCallExpression": (expr:expressions.MxPropertyCallExpression) => operand === undefined ? undefined : operand[expr.referredProperty], | ||
"MxQualifiedEnumLiteralExpression": (expr:expressions.MxQualifiedEnumLiteralExpression) => evalQualifiedEnumLiteral(expr), | ||
"MxSizeLiteralExpression": (expr:expressions.MxSizeLiteralExpression) => { return { height: expr.height, width: expr.width } }, | ||
"MxStringLiteralExpression": (expr:expressions.MxStringLiteralExpression) => expr.value, | ||
"MxStructureLiteralExpression": (expr:expressions.MxStructureLiteralExpression) => evalStructureLiteral(expr, operand, variables), | ||
"MxThisExpression": (expr:expressions.MxThisExpression) => structure, | ||
"MxUndefinedExpression": (expr:expressions.MxUndefinedExpression) => undefined, | ||
"MxVariableRefExpression": (expr:expressions.MxVariableRefExpression) => variables.get(expr.referredVariable) | ||
}; | ||
const evalFn = polyMap[expr_.$type]; | ||
if (!evalFn) | ||
throw new Error(`unhandled expression type: ${expr_.$type}`); | ||
return evalFn(expr_); | ||
} | ||
} | ||
function evalStructureLiteral(expr, operand, variables) { | ||
var assignments = {}; | ||
for (var _i = 0, _a = expr.assignments; _i < _a.length; _i++) { | ||
var assignment = _a[_i]; | ||
var evalAssignment = evalInt(assignment.value, operand, variables); | ||
if (evalAssignment === undefined) | ||
function evalBinary(expr:expressions.MxBinaryExpression, operand:any, variables: Closure): any { | ||
if (expr.operator === expressions.MxOperator.NONE) | ||
throw new Error('sentinel value of MxOperator not allowed in runtime'); | ||
const evalLeft = evalInt(expr.left, operand, variables); | ||
const evalRight = evalInt(expr.right, operand, variables); // (no shortcutting (yet?)) | ||
if (evalLeft === undefined || evalRight === undefined) { | ||
return undefined; // simple failure semantics: propagate undefined | ||
} | ||
switch (expr.operator) { | ||
case expressions.MxOperator.AND: return evalLeft && evalRight; | ||
case expressions.MxOperator.EQUALS: return evalLeft === evalRight; | ||
case expressions.MxOperator.GREATER: return evalLeft > evalRight; // (no type coercion?) | ||
case expressions.MxOperator.GREATER_OR_EQUALS: return (evalLeft > evalRight) || (evalLeft === evalRight); // (some type coercion) | ||
case expressions.MxOperator.LESS: return evalLeft < evalRight; // (no type coercion?) | ||
case expressions.MxOperator.LESS_OR_EQUALS: return (evalLeft < evalRight) || (evalLeft === evalRight); // (some type coercion) | ||
case expressions.MxOperator.OR: return evalLeft || evalRight; | ||
case expressions.MxOperator.UNEQUALS: return evalLeft !== evalRight; | ||
default: return undefined; | ||
} | ||
} | ||
function evalStructureLiteral(expr:expressions.MxStructureLiteralExpression, operand:any, variables:Closure):any { | ||
const assignments:{ [propertyName:string]:any } = {}; | ||
for (let assignment of expr.assignments) { | ||
const evalAssignment = evalInt(assignment.value, operand, variables); | ||
if (evalAssignment === undefined) | ||
return undefined; | ||
assignments[assignment.property] = evalAssignment; | ||
} | ||
const clazz = instancehelpers.lookupClass(expr.structure, modelClasses); | ||
if (!clazz) | ||
return undefined; | ||
assignments[assignment.property] = evalAssignment; | ||
const structure = clazz.create(model); | ||
if (!structure) | ||
return undefined; | ||
for (let propertyName in assignments) { | ||
structure['__' + propertyName].set(assignments[propertyName]); | ||
} | ||
return structure; | ||
} | ||
var clazz = instances_1.instancehelpers.lookupClass(expr.structure, modelClasses); | ||
if (!clazz) | ||
return undefined; | ||
var structure = clazz.create(model); | ||
if (!structure) | ||
return undefined; | ||
for (var propertyName in assignments) { | ||
structure['__' + propertyName].set(assignments[propertyName]); | ||
function evalQualifiedEnumLiteral(expr:expressions.MxQualifiedEnumLiteralExpression) { | ||
const enumClazz = instancehelpers.lookupClass(expr.enumeration, modelClasses); | ||
if (!enumClazz) | ||
return undefined; | ||
const literal = enumClazz[expr.literal]; | ||
if (!literal) | ||
return undefined; | ||
return literal; | ||
} | ||
return structure; | ||
} | ||
function evalQualifiedEnumLiteral(expr) { | ||
var enumClazz = instances_1.instancehelpers.lookupClass(expr.enumeration, modelClasses); | ||
if (!enumClazz) | ||
return undefined; | ||
var literal = enumClazz[expr.literal]; | ||
if (!literal) | ||
return undefined; | ||
return literal; | ||
} | ||
*/ | ||
} | ||
exports.evaluateExpr = evaluateExpr; |
@@ -83,6 +83,3 @@ var fs = require('fs'); | ||
try { | ||
console.log(rawDeploymentResult); | ||
debugger; | ||
var result = this.parseRawDeploymentResult(rawDeploymentResult); | ||
console.log("parsed", result); | ||
} | ||
@@ -89,0 +86,0 @@ catch (e) { |
@@ -1,2 +0,2 @@ | ||
/** Current SDK version: 2.1.0-dev.0a1a07 */ | ||
/** Current SDK version: 2.1.0-dev.d2d1402 */ | ||
export declare const SDK_VERSION: string; |
@@ -1,2 +0,2 @@ | ||
/** Current SDK version: 2.1.0-dev.0a1a07 */ | ||
/** Current SDK version: 2.1.0-dev.d2d1402 */ | ||
exports.SDK_VERSION = "2.1.0"; |
@@ -26,3 +26,3 @@ /// <reference path="../../test-typings.d.ts"/> | ||
} | ||
it('a binary expression with faulty or failing data', function () { | ||
it.skip('a binary expression with faulty or failing data', function () { | ||
chai_1.assert.throws(function () { | ||
@@ -35,3 +35,3 @@ evaluateNoContext({ $type: "MxBinaryExpression", left: null, operator: expressions.MxOperator.NONE, right: null }); | ||
}); | ||
it('a binary expression with valid data', function () { | ||
it.skip('a binary expression with valid data', function () { | ||
assertEvalNoContext(mkBinaryExpr(mkBooleanLiteral(true), expressions.MxOperator.AND, mkBooleanLiteral(false)), false); | ||
@@ -41,19 +41,15 @@ assertEvalNoContext(mkBinaryExpr(mkBooleanLiteral(true), expressions.MxOperator.AND, mkBooleanLiteral(true)), true); | ||
assertEvalNoContext(mkBinaryExpr(mkBooleanLiteral(false), expressions.MxOperator.OR, mkBooleanLiteral(false)), false); | ||
assertEvalNoContext(mkBinaryExpr(mkBooleanLiteral(true), expressions.MxOperator.IMPLIES, mkBooleanLiteral(true)), true); | ||
assertEvalNoContext(mkBinaryExpr(mkBooleanLiteral(true), expressions.MxOperator.IMPLIES, mkBooleanLiteral(false)), false); | ||
assertEvalNoContext(mkBinaryExpr(mkBooleanLiteral(false), expressions.MxOperator.IMPLIES, mkBooleanLiteral(true)), true); | ||
assertEvalNoContext(mkBinaryExpr(mkBooleanLiteral(false), expressions.MxOperator.IMPLIES, mkBooleanLiteral(false)), true); | ||
// TODO test cases for all other operators | ||
}); | ||
it('a boolean literal expression', function () { | ||
it.skip('a boolean literal expression', function () { | ||
assertEvalNoContext(mkBooleanLiteral(true), true); | ||
assertEvalNoContext(mkBooleanLiteral(false), false); | ||
}); | ||
it('a color literal expression', function () { | ||
it.skip('a color literal expression', function () { | ||
assertEvalNoContext({ $type: "MxColorLiteralExpression", red: 100, green: 150, blue: 200 }, { red: 100, green: 150, blue: 200 }); | ||
}); | ||
it('a double literal expression', function () { | ||
it.skip('a double literal expression', function () { | ||
assertEvalNoContext({ $type: "MxDoubleLiteralExpression", value: Math.PI }, Math.PI); | ||
}); | ||
it('a (unqualified) enum literal expression', function () { | ||
it.skip('a (unqualified) enum literal expression', function () { | ||
chai_1.assert.throws(function () { | ||
@@ -63,6 +59,6 @@ evaluateNoContext({ $type: "MxEnumLiteralExpression", enumLiteral: "n'importe quoi" }); | ||
}); | ||
it('a integer literal expression', function () { | ||
it.skip('a integer literal expression', function () { | ||
assertEvalNoContext({ $type: "MxIntegerLiteralExpression", value: 42 }, 42); | ||
}); | ||
it('a [collect] iterator call expression (and implicitly a variable reference expression)', function (done) { | ||
it.skip('a [collect] iterator call expression (and implicitly a variable reference expression)', function (done) { | ||
test_model_helper_1.withEntityLoaded("6.1.0", done, function (entity, domainModel, model) { | ||
@@ -77,3 +73,3 @@ var entity2 = domainmodels_simple_1.domainmodels_simple.Entity.createIn(domainModel); | ||
}); | ||
it('[collect and flatten] iterator call expressions (and implicitly a variable reference expression)', function (done) { | ||
it.skip('[collect and flatten] iterator call expressions (and implicitly a variable reference expression)', function (done) { | ||
test_model_helper_1.withEntityLoaded("6.1.0", done, function (entity, domainModel, model) { | ||
@@ -90,3 +86,3 @@ var attribute2 = domainmodels_simple_1.domainmodels_simple.Attribute.createIn(entity); | ||
}); | ||
it('a list literal expression', function () { | ||
it.skip('a list literal expression', function () { | ||
assertEvalNoContext({ $type: "MxListLiteralExpression", items: [ | ||
@@ -100,3 +96,3 @@ mkBooleanLiteral(true), | ||
}); | ||
it('a prefix (==boolean negation) expression', function () { | ||
it.skip('a prefix (==boolean negation) expression', function () { | ||
assertEvalNoContext({ $type: "MxPrefixExpression", expression: mkBooleanLiteral(true) }, false); | ||
@@ -106,3 +102,3 @@ assertEvalNoContext({ $type: "MxPrefixExpression", expression: mkBooleanLiteral(false) }, true); | ||
}); | ||
it('a property call expression', function (done) { | ||
it.skip('a property call expression', function (done) { | ||
test_model_helper_1.withEntityLoaded("6.1.0", done, function (entity, domainModel, model) { | ||
@@ -117,3 +113,3 @@ var entityName = "fooBar!"; | ||
}); | ||
it('a qualified enum literal expression', function (done) { | ||
it.skip('a qualified enum literal expression', function (done) { | ||
test_model_helper_1.withEntityLoaded("6.1.0", done, function (entity, domainModel, model) { | ||
@@ -129,9 +125,9 @@ var value = expressions_evaluator_1.evaluateExpr({ | ||
}); | ||
it('a size literal expression', function () { | ||
it.skip('a size literal expression', function () { | ||
assertEvalNoContext({ $type: "MxSizeLiteralExpression", height: 1000, width: 800 }, { height: 1000, width: 800 }); | ||
}); | ||
it('a string literal expression', function () { | ||
it.skip('a string literal expression', function () { | ||
assertEvalNoContext(mkStringLiteral("foo"), "foo"); | ||
}); | ||
it('a structure literal expression', function (done) { | ||
it.skip('a structure literal expression', function (done) { | ||
function mkPropertyAssignment(propertyName, valueExpr) { | ||
@@ -159,3 +155,3 @@ return { | ||
}); | ||
it('a this expression', function (done) { | ||
it.skip('a this expression', function (done) { | ||
test_model_helper_1.withEntityLoaded("6.1.0", done, function (entity, domainModel, model) { | ||
@@ -171,5 +167,5 @@ var entityName = "fooBar!"; | ||
}); | ||
it('an undefined expression', function () { | ||
it.skip('an undefined expression', function () { | ||
assertEvalNoContext(undefinedExpr, undefined); | ||
}); | ||
}); |
@@ -6,120 +6,131 @@ /// <reference path="../../test-typings.d.ts"/> | ||
describe('expressions parser', function () { | ||
it('should parse example expression 1', function (done) { | ||
chai_1.assert.deepEqual(expressions_parser_1.parseExpression("this.entities.collect[ ent | ent.name ]"), { | ||
$type: "MxNavigationExpression", | ||
base: { | ||
$type: "MxThisExpression" | ||
}, | ||
tail: { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: { | ||
$type: "MxPropertyCallExpression", | ||
referredProperty: 'entities' | ||
it.skip('should parse example expression 1', function (done) { | ||
/* TODO: enable again | ||
assert.deepEqual( | ||
parseExpression("this.entities.collect[ ent | ent.name ]"), | ||
{ | ||
$type: "MxNavigationExpression", | ||
base: <expressions.MxThisExpression> { | ||
$type: "MxThisExpression" | ||
}, | ||
tail: { | ||
tail: <expressions.MxFeatureCallExpressionWrapper> { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: { | ||
$type: "MxIteratorCallExpression", | ||
referredIterator: "collect", | ||
variable: { | ||
$type: "MxIteratorVariableDeclaration", | ||
name: "ent" | ||
}, | ||
body: { | ||
$type: "MxNavigationExpression", | ||
base: { | ||
$type: "MxVariableRefExpression", | ||
referredVariable: "ent" | ||
featureCall: <expressions.MxPropertyCallExpression> { | ||
$type: "MxPropertyCallExpression", | ||
referredProperty: 'entities' | ||
}, | ||
tail: <expressions.MxFeatureCallExpressionWrapper> { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: <expressions.MxIteratorCallExpression> { | ||
$type: "MxIteratorCallExpression", | ||
referredIterator: "collect", | ||
variable: { | ||
$type: "MxIteratorVariableDeclaration", | ||
name: "ent" | ||
}, | ||
tail: { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: { | ||
$type: "MxPropertyCallExpression", | ||
referredProperty: 'name' | ||
body: <expressions.MxNavigationExpression>{ | ||
$type: "MxNavigationExpression", | ||
base: <expressions.MxVariableRefExpression> { | ||
$type: "MxVariableRefExpression", | ||
referredVariable: "ent" | ||
}, | ||
tail: null | ||
tail: <expressions.MxFeatureCallExpressionWrapper> { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: <expressions.MxPropertyCallExpression> { | ||
$type: "MxPropertyCallExpression", | ||
referredProperty: 'name' | ||
}, | ||
tail: null | ||
} | ||
} | ||
} | ||
}, | ||
tail: null | ||
}, | ||
tail: null | ||
} | ||
} | ||
} | ||
}); | ||
); | ||
*/ | ||
done(); | ||
}); | ||
it('should parse example expression 2', function (done) { | ||
chai_1.assert.deepEqual(expressions_parser_1.parseExpression("this.entities.collect[ ent | ent.attributes.collect [ attr | attr.name ]].flatten()"), { | ||
$type: "MxNavigationExpression", | ||
base: { | ||
$type: "MxThisExpression" | ||
}, | ||
tail: { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: { | ||
$type: "MxPropertyCallExpression", | ||
referredProperty: 'entities' | ||
it.skip('should parse example expression 2', function (done) { | ||
/* TODO: enable again | ||
assert.deepEqual( | ||
parseExpression("this.entities.collect[ ent | ent.attributes.collect [ attr | attr.name ]].flatten()"), | ||
{ | ||
$type: "MxNavigationExpression", | ||
base: <expressions.MxThisExpression> { | ||
$type: "MxThisExpression" | ||
}, | ||
tail: { | ||
tail: <expressions.MxFeatureCallExpressionWrapper> { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: { | ||
$type: "MxIteratorCallExpression", | ||
referredIterator: "collect", | ||
variable: { | ||
$type: "MxIteratorVariableDeclaration", | ||
name: "ent" | ||
}, | ||
body: { | ||
$type: "MxNavigationExpression", | ||
base: { | ||
$type: "MxVariableRefExpression", | ||
referredVariable: "ent" | ||
featureCall: <expressions.MxPropertyCallExpression> { | ||
$type: "MxPropertyCallExpression", | ||
referredProperty: 'entities' | ||
}, | ||
tail: <expressions.MxFeatureCallExpressionWrapper> { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: <expressions.MxIteratorCallExpression> { | ||
$type: "MxIteratorCallExpression", | ||
referredIterator: "collect", | ||
variable: { | ||
$type: "MxIteratorVariableDeclaration", | ||
name: "ent" | ||
}, | ||
tail: { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: { | ||
$type: "MxPropertyCallExpression", | ||
referredProperty: 'attributes' | ||
body: <expressions.MxNavigationExpression>{ | ||
$type: "MxNavigationExpression", | ||
base: <expressions.MxVariableRefExpression> { | ||
$type: "MxVariableRefExpression", | ||
referredVariable: "ent" | ||
}, | ||
tail: { | ||
tail: <expressions.MxFeatureCallExpressionWrapper> { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: { | ||
$type: "MxIteratorCallExpression", | ||
referredIterator: "collect", | ||
variable: { | ||
$type: "MxIteratorVariableDeclaration", | ||
name: "attr" | ||
}, | ||
body: { | ||
$type: "MxNavigationExpression", | ||
base: { | ||
$type: "MxVariableRefExpression", | ||
referredVariable: "attr" | ||
featureCall: <expressions.MxPropertyCallExpression> { | ||
$type: "MxPropertyCallExpression", | ||
referredProperty: 'attributes' | ||
}, | ||
tail: <expressions.MxFeatureCallExpressionWrapper> { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: <expressions.MxIteratorCallExpression> { | ||
$type: "MxIteratorCallExpression", | ||
referredIterator: "collect", | ||
variable: { | ||
$type: "MxIteratorVariableDeclaration", | ||
name: "attr" | ||
}, | ||
tail: { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: { | ||
$type: "MxPropertyCallExpression", | ||
referredProperty: 'name' | ||
body: <expressions.MxNavigationExpression>{ | ||
$type: "MxNavigationExpression", | ||
base: <expressions.MxVariableRefExpression> { | ||
$type: "MxVariableRefExpression", | ||
referredVariable: "attr" | ||
}, | ||
tail: null | ||
tail: <expressions.MxFeatureCallExpressionWrapper> { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: <expressions.MxPropertyCallExpression> { | ||
$type: "MxPropertyCallExpression", | ||
referredProperty: 'name' | ||
}, | ||
tail: null | ||
} | ||
} | ||
} | ||
}, | ||
tail: null | ||
}, | ||
tail: null | ||
} | ||
} | ||
} | ||
}, | ||
tail: { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: <expressions.MxMethodCallExpression> { | ||
$type: "MxMethodCallExpression", | ||
referredMethod: "flatten" | ||
}, | ||
tail: null | ||
} | ||
}, | ||
tail: { | ||
$type: "MxFeatureCallExpressionWrapper", | ||
featureCall: { | ||
$type: "MxMethodCallExpression", | ||
referredMethod: "flatten" | ||
}, | ||
tail: null | ||
} | ||
} | ||
} | ||
}); | ||
); | ||
done(); | ||
*/ | ||
}); | ||
@@ -126,0 +137,0 @@ it('should parse "this.name"', function () { |
@@ -33,3 +33,3 @@ /// <reference path="../../test-typings.d.ts"/> | ||
it('a binary expression with faulty or failing data', () => { | ||
it.skip('a binary expression with faulty or failing data', () => { | ||
assert.throws(() => { | ||
@@ -43,3 +43,3 @@ evaluateNoContext(<expressions.MxBinaryExpression>{ $type: "MxBinaryExpression", left: null, operator: expressions.MxOperator.NONE, right: null }); | ||
it('a binary expression with valid data', () => { | ||
it.skip('a binary expression with valid data', () => { | ||
assertEvalNoContext(mkBinaryExpr(mkBooleanLiteral(true), expressions.MxOperator.AND, mkBooleanLiteral(false)), false); | ||
@@ -51,11 +51,6 @@ assertEvalNoContext(mkBinaryExpr(mkBooleanLiteral(true), expressions.MxOperator.AND, mkBooleanLiteral(true)), true); | ||
assertEvalNoContext(mkBinaryExpr(mkBooleanLiteral(true), expressions.MxOperator.IMPLIES, mkBooleanLiteral(true)), true); | ||
assertEvalNoContext(mkBinaryExpr(mkBooleanLiteral(true), expressions.MxOperator.IMPLIES, mkBooleanLiteral(false)), false); | ||
assertEvalNoContext(mkBinaryExpr(mkBooleanLiteral(false), expressions.MxOperator.IMPLIES, mkBooleanLiteral(true)), true); | ||
assertEvalNoContext(mkBinaryExpr(mkBooleanLiteral(false), expressions.MxOperator.IMPLIES, mkBooleanLiteral(false)), true); | ||
// TODO test cases for all other operators | ||
}); | ||
it('a boolean literal expression', () => { | ||
it.skip('a boolean literal expression', () => { | ||
assertEvalNoContext(mkBooleanLiteral(true), true); | ||
@@ -65,11 +60,11 @@ assertEvalNoContext(mkBooleanLiteral(false), false); | ||
it('a color literal expression', () => { | ||
it.skip('a color literal expression', () => { | ||
assertEvalNoContext(<expressions.MxColorLiteralExpression>{ $type: "MxColorLiteralExpression", red: 100, green: 150, blue: 200 }, { red: 100, green: 150, blue: 200 }); | ||
}); | ||
it('a double literal expression', () => { | ||
it.skip('a double literal expression', () => { | ||
assertEvalNoContext(<expressions.MxDoubleLiteralExpression>{ $type: "MxDoubleLiteralExpression", value: Math.PI }, Math.PI); | ||
}); | ||
it('a (unqualified) enum literal expression', () => { | ||
it.skip('a (unqualified) enum literal expression', () => { | ||
assert.throws(() => { | ||
@@ -80,7 +75,7 @@ evaluateNoContext(<expressions.MxEnumLiteralExpression>{ $type: "MxEnumLiteralExpression", enumLiteral: "n'importe quoi" }); | ||
it('a integer literal expression', () => { | ||
it.skip('a integer literal expression', () => { | ||
assertEvalNoContext(<expressions.MxIntegerLiteralExpression>{ $type: "MxIntegerLiteralExpression", value: 42 }, 42); | ||
}); | ||
it('a [collect] iterator call expression (and implicitly a variable reference expression)', done => { | ||
it.skip('a [collect] iterator call expression (and implicitly a variable reference expression)', done => { | ||
withEntityLoaded("6.1.0", done, (entity, domainModel, model) => { // (ignore warnings issued) | ||
@@ -97,3 +92,3 @@ const entity2 = domainmodels_simple.Entity.createIn(domainModel); | ||
it('[collect and flatten] iterator call expressions (and implicitly a variable reference expression)', done => { | ||
it.skip('[collect and flatten] iterator call expressions (and implicitly a variable reference expression)', done => { | ||
withEntityLoaded("6.1.0", done, (entity, domainModel, model) => { // (ignore warnings issued) | ||
@@ -113,3 +108,3 @@ const attribute2 = domainmodels_simple.Attribute.createIn(entity); | ||
it('a list literal expression', () => { | ||
it.skip('a list literal expression', () => { | ||
assertEvalNoContext(<expressions.MxListLiteralExpression>{ $type: "MxListLiteralExpression", items: [ | ||
@@ -124,3 +119,3 @@ mkBooleanLiteral(true), | ||
it('a prefix (==boolean negation) expression', () => { | ||
it.skip('a prefix (==boolean negation) expression', () => { | ||
assertEvalNoContext(<expressions.MxPrefixExpression>{ $type: "MxPrefixExpression", expression: mkBooleanLiteral(true) }, false); | ||
@@ -131,3 +126,3 @@ assertEvalNoContext(<expressions.MxPrefixExpression>{ $type: "MxPrefixExpression", expression: mkBooleanLiteral(false) }, true); | ||
it('a property call expression', done => { | ||
it.skip('a property call expression', done => { | ||
withEntityLoaded("6.1.0", done, (entity, domainModel, model) => { // (ignore warnings issued) | ||
@@ -143,3 +138,3 @@ const entityName = "fooBar!"; | ||
it('a qualified enum literal expression', done => { | ||
it.skip('a qualified enum literal expression', done => { | ||
withEntityLoaded("6.1.0", done, (entity, domainModel, model) => { // (ignore warnings issued) | ||
@@ -156,11 +151,11 @@ const value = evaluateExpr(<expressions.MxQualifiedEnumLiteralExpression>{ | ||
it('a size literal expression', () => { | ||
it.skip('a size literal expression', () => { | ||
assertEvalNoContext(<expressions.MxSizeLiteralExpression>{ $type: "MxSizeLiteralExpression", height: 1000, width: 800 }, { height: 1000, width: 800 }); | ||
}); | ||
it('a string literal expression', () => { | ||
it.skip('a string literal expression', () => { | ||
assertEvalNoContext(mkStringLiteral("foo"), "foo"); | ||
}); | ||
it('a structure literal expression', done => { | ||
it.skip('a structure literal expression', done => { | ||
function mkPropertyAssignment(propertyName:string, valueExpr:expressions.MxLiteralExpression):expressions.MxPropertyAssignment { | ||
@@ -189,3 +184,3 @@ return { | ||
it('a this expression', (done) => { | ||
it.skip('a this expression', (done) => { | ||
withEntityLoaded("6.1.0", done, (entity, domainModel, model) => { // (ignore warnings issued) | ||
@@ -202,3 +197,3 @@ const entityName = "fooBar!"; | ||
it('an undefined expression', () => { | ||
it.skip('an undefined expression', () => { | ||
assertEvalNoContext(undefinedExpr, undefined); | ||
@@ -205,0 +200,0 @@ }); |
@@ -13,3 +13,4 @@ /// <reference path="../../test-typings.d.ts"/> | ||
it('should parse example expression 1', done => { | ||
it.skip('should parse example expression 1', done => { | ||
/* TODO: enable again | ||
assert.deepEqual( | ||
@@ -58,3 +59,3 @@ parseExpression("this.entities.collect[ ent | ent.name ]"), | ||
); | ||
*/ | ||
done(); | ||
@@ -64,3 +65,4 @@ }); | ||
it('should parse example expression 2', done => { | ||
it.skip('should parse example expression 2', done => { | ||
/* TODO: enable again | ||
assert.deepEqual( | ||
@@ -144,2 +146,3 @@ parseExpression("this.entities.collect[ ent | ent.attributes.collect [ attr | attr.name ]].flatten()"), | ||
done(); | ||
*/ | ||
}); | ||
@@ -146,0 +149,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5084289
94906