Code coverage report for lib\BasicEvaluatedExpression.js

Statements: 72.64% (77 / 106)      Branches: 36.96% (17 / 46)      Functions: 92% (23 / 25)      Lines: 81.72% (76 / 93)      Ignored: none     

All files » lib\ » BasicEvaluatedExpression.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135        1 90343   1   1 30361   1 16475   1 13893   1 10249   1 4929   1 14041   1 13450   1 48145   1 13128   1 10402 9799 9799 9799 9799 9799 9799 9799   1               1 15332     15332 15332   1 1715     1715 1715   1 1572     1572 1572   1 114     114 114   1 10958     10958 10958   1 2600 2600 2600   1         1 630     630 630   1 1514     1514 1514   1 30     30 30   1 630 630 879   630   1 89011 89011          
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
function BasicEvaluatedExpression() {
	this.range = null;
}
module.exports = BasicEvaluatedExpression;
 
BasicEvaluatedExpression.prototype.isString = function() {
	return Object.prototype.hasOwnProperty.call(this, "string");
};
BasicEvaluatedExpression.prototype.isNumber = function() {
	return Object.prototype.hasOwnProperty.call(this, "number");
};
BasicEvaluatedExpression.prototype.isBoolean = function() {
	return Object.prototype.hasOwnProperty.call(this, "bool");
};
BasicEvaluatedExpression.prototype.isRegExp = function() {
	return Object.prototype.hasOwnProperty.call(this, "regExp");
};
BasicEvaluatedExpression.prototype.isConditional = function() {
	return Object.prototype.hasOwnProperty.call(this, "options");
};
BasicEvaluatedExpression.prototype.isArray = function() {
	return Object.prototype.hasOwnProperty.call(this, "items");
};
BasicEvaluatedExpression.prototype.isConstArray = function() {
	return Object.prototype.hasOwnProperty.call(this, "array");
};
BasicEvaluatedExpression.prototype.isIdentifier = function() {
	return Object.prototype.hasOwnProperty.call(this, "identifier");
};
BasicEvaluatedExpression.prototype.isWrapped = function() {
	return Object.prototype.hasOwnProperty.call(this, "prefix");
};
BasicEvaluatedExpression.prototype.asBool = function() {
	if(this.isBoolean()) return this.bool;
	else Iif(this.isString()) return !!this.string;
	else Iif(this.isNumber()) return !!this.number;
	else Iif(this.isRegExp()) return true;
	else Iif(this.isArray()) return true;
	else Iif(this.isConstArray()) return true;
	else Iif(this.isWrapped()) return this.prefix || this.postfix ? true : undefined;
	return undefined;
};
BasicEvaluatedExpression.prototype.set = function(value) {
	if(typeof value === "string") return this.setString(value);
	if(typeof value === "number") return this.setNumber(value);
	if(typeof value === "boolean") return this.setBoolean(value);
	if(value instanceof RegExp) return this.setRegExp(value);
	if(Array.isArray(value)) return this.setArray(value);
	return this;
};
BasicEvaluatedExpression.prototype.setString = function(str) {
	Iif(str === null)
		delete this.string;
	else
		this.string = str;
	return this;
};
BasicEvaluatedExpression.prototype.setNumber = function(num) {
	Iif(num === null)
		delete this.number;
	else
		this.number = num;
	return this;
};
BasicEvaluatedExpression.prototype.setBoolean = function(bool) {
	Iif(bool === null)
		delete this.bool;
	else
		this.bool = bool;
	return this;
};
BasicEvaluatedExpression.prototype.setRegExp = function(regExp) {
	Iif(regExp === null)
		delete this.regExp;
	else
		this.regExp = regExp;
	return this;
};
BasicEvaluatedExpression.prototype.setIdentifier = function(identifier) {
	Iif(identifier === null)
		delete this.identifier;
	else
		this.identifier = identifier;
	return this;
};
BasicEvaluatedExpression.prototype.setWrapped = function(prefix, postfix) {
	this.prefix = prefix;
	this.postfix = postfix;
	return this;
};
BasicEvaluatedExpression.prototype.unsetWrapped = function() {
	delete this.prefix;
	delete this.postfix;
	return this;
};
BasicEvaluatedExpression.prototype.setOptions = function(options) {
	Iif(options === null)
		delete this.options;
	else
		this.options = options;
	return this;
};
BasicEvaluatedExpression.prototype.setItems = function(items) {
	Iif(items === null)
		delete this.items;
	else
		this.items = items;
	return this;
};
BasicEvaluatedExpression.prototype.setArray = function(array) {
	Iif(array === null)
		delete this.array;
	else
		this.array = array;
	return this;
};
BasicEvaluatedExpression.prototype.addOptions = function(options) {
	Iif(!this.options) this.options = [];
	options.forEach(function(item) {
		this.options.push(item);
	}, this);
	return this;
};
BasicEvaluatedExpression.prototype.setRange = function(range) {
	this.range = range;
	return this;
};