UNPKG

js-contracts

Version:
40 lines 2.12 kB
"use strict"; 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); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var contract_1 = __importDefault(require("./contract")); contract_1.default.setSettings({ shouldFailOnCondition: true, shouldSkipContractChecks: false }); var Func = /** @class */ (function () { function Func() { this.test = 'hi'; this.test = 'hi!'; } Func.prototype.test_ensures = function () { this.test = 'yo'; contract_1.default.Assert(function (test) { return test === 'hi'; }, 'not cool!')(this.test); var collection = [this.test]; console.log(collection); contract_1.default.Exists(collection, function (item) { return item === 'hi'; }, 'fcuk'); return this.test; }; __decorate([ contract_1.default.Ensures(function (instance) { return contract_1.default.OldValueByPath('instance.test') === contract_1.default.ContractResult(); }, 'Result should not be null'), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Object) ], Func.prototype, "test_ensures", null); return Func; }()); var f = new Func(); var result = f.test_ensures(); //# sourceMappingURL=test.js.map