UNPKG

web-atoms-core

Version:
143 lines • 7.6 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "@web-atoms/unit-test/dist/Assert", "@web-atoms/unit-test/dist/Test", "../../core/ExpressionParser", "../../unit/AtomTest"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Assert_1 = require("@web-atoms/unit-test/dist/Assert"); var Test_1 = require("@web-atoms/unit-test/dist/Test"); var ExpressionParser_1 = require("../../core/ExpressionParser"); var AtomTest_1 = require("../../unit/AtomTest"); var ExpressionParserTest = /** @class */ (function (_super) { __extends(ExpressionParserTest, _super); function ExpressionParserTest() { return _super !== null && _super.apply(this, arguments) || this; } ExpressionParserTest.prototype.parse = function () { // tslint:disable-next-line:variable-name var _this = {}; var p = ExpressionParser_1.parsePath(function () { _this.value = _this.v1 + _this.m2(_this.v2, _this.m4(_this.v3, _this.v4)); for (var _i = 0, _a = _this.v5; _i < _a.length; _i++) { var iterator = _a[_i]; _this.av = _this.v1 + _this.v2; // tslint:disable-next-line if (_this.v6 == _this.v7 && _this.v8 === _this.v9) { // tslint:disable-next-line:no-console console.log("ok"); } } }); // tslint:disable-next-line:no-console // console.log(JSON.stringify(p, undefined, 2)); Assert_1.default.equals(9, p.filter(function (px) { return /^v/.test(px[0]); }).length); Assert_1.default.equals(0, p.filter(function (px) { return !/^v/.test(px[0]); }).length); }; ExpressionParserTest.prototype.parseLambda = function () { var p = ExpressionParser_1.parsePath(function (a) { return a.firstName + " " + a.lastName; }); Assert_1.default.equals(2, p.length); }; ExpressionParserTest.prototype.parseLambdaText = function () { var p = ExpressionParser_1.parsePath("function(a) { return a.firstName + ' ' + a.lastName; }"); Assert_1.default.equals(2, p.length); }; ExpressionParserTest.prototype.parseLambdaTextWithSecondParameter = function () { var p = ExpressionParser_1.parsePath("function(a, b) { return a.firstName + ' ' + a.lastName; }"); Assert_1.default.equals(2, p.length); }; ExpressionParserTest.prototype.parseLambdaTextWithComments = function () { var p = ExpressionParser_1.parsePath("function(a) {\n // test a.firstName\n return a.firstName + ' ' + a.lastName;\n }"); Assert_1.default.equals(2, p.length); }; ExpressionParserTest.prototype.parse1 = function () { var p = ExpressionParser_1.parsePath("function () {\n this.dateChange(this.month, this.year);\n }"); Assert_1.default.equals(2, p.length); }; ExpressionParserTest.prototype.parse2 = function () { var p = ExpressionParser_1.parsePath("function () {\n this.dateChange(this[\"month\"], this.year);\n }"); Assert_1.default.equals(1, p.length); }; ExpressionParserTest.prototype.parseLongPath = function () { var p = ExpressionParser_1.parsePathLists("function () {\n return _this.viewModel.comboBox.searchText;\n }"); Assert_1.default.equals(1, p.thisPath.length); }; __decorate([ Test_1.default, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ExpressionParserTest.prototype, "parse", null); __decorate([ Test_1.default, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ExpressionParserTest.prototype, "parseLambda", null); __decorate([ Test_1.default, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ExpressionParserTest.prototype, "parseLambdaText", null); __decorate([ Test_1.default, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ExpressionParserTest.prototype, "parseLambdaTextWithSecondParameter", null); __decorate([ Test_1.default, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ExpressionParserTest.prototype, "parseLambdaTextWithComments", null); __decorate([ Test_1.default, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ExpressionParserTest.prototype, "parse1", null); __decorate([ Test_1.default, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ExpressionParserTest.prototype, "parse2", null); __decorate([ Test_1.default, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ExpressionParserTest.prototype, "parseLongPath", null); return ExpressionParserTest; }(AtomTest_1.AtomTest)); exports.ExpressionParserTest = ExpressionParserTest; }); //# sourceMappingURL=ExpressionParserTest.js.map