|
| 1 | +/** |
| 2 | + * Copyright (c) 2002-2017 "Neo Technology,"," |
| 3 | + * Network Engine for Objects in Lund AB [http://neotechnology.com] |
| 4 | + * |
| 5 | + * This file is part of Neo4j. |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +import Integer, {inSafeRange, int, isInt, toNumber, toString} from "../../../types/v1/integer"; |
| 21 | + |
| 22 | +const int1 = new Integer(); |
| 23 | +const int2 = new Integer(1); |
| 24 | +const int3 = new Integer(1, 2); |
| 25 | + |
| 26 | +const high: number = int1.high; |
| 27 | +const low: number = int1.low; |
| 28 | + |
| 29 | +const safe: boolean = int1.inSafeRange(); |
| 30 | +if (safe) { |
| 31 | + const i: number = int1.toInt(); |
| 32 | + console.log(i); |
| 33 | + |
| 34 | + const n: number = int1.toNumber(); |
| 35 | + console.log(n) |
| 36 | +} |
| 37 | + |
| 38 | +const str: string = int2.toString(16); |
| 39 | + |
| 40 | +const highBits: number = int3.getHighBits(); |
| 41 | +const lowBits: number = int3.getLowBits(); |
| 42 | +const numBitsAbs: number = int3.getNumBitsAbs(); |
| 43 | + |
| 44 | +const isZero: boolean = int1.isZero(); |
| 45 | +const isNegative: boolean = int1.isNegative(); |
| 46 | +const isPositive: boolean = int1.isPositive(); |
| 47 | +const isOdd: boolean = int1.isOdd(); |
| 48 | +const isEven: boolean = int1.isEven(); |
| 49 | + |
| 50 | +const eq1: boolean = int1.equals(int2); |
| 51 | +const eq2: boolean = int1.equals(42); |
| 52 | +const eq3: boolean = int1.equals("42"); |
| 53 | + |
| 54 | +const neq1: boolean = int1.notEquals(int2); |
| 55 | +const neq2: boolean = int1.notEquals(42); |
| 56 | +const neq3: boolean = int1.notEquals("42"); |
| 57 | + |
| 58 | +const lt1: boolean = int1.lessThan(int2); |
| 59 | +const lt2: boolean = int1.lessThan(42); |
| 60 | +const lt3: boolean = int1.lessThan("42"); |
| 61 | + |
| 62 | +const lte1: boolean = int1.lessThanOrEqual(int2); |
| 63 | +const lte2: boolean = int1.lessThanOrEqual(42); |
| 64 | +const lte3: boolean = int1.lessThanOrEqual("42"); |
| 65 | + |
| 66 | +const gt1: boolean = int1.greaterThan(int2); |
| 67 | +const gt2: boolean = int1.greaterThan(42); |
| 68 | +const gt3: boolean = int1.greaterThan("42"); |
| 69 | + |
| 70 | +const gte1: boolean = int1.greaterThanOrEqual(int2); |
| 71 | +const gte2: boolean = int1.greaterThanOrEqual(42); |
| 72 | +const gte3: boolean = int1.greaterThanOrEqual("42"); |
| 73 | + |
| 74 | +const cmp1: number = int2.compare(int3); |
| 75 | +const cmp2: number = int2.compare(42); |
| 76 | +const cmp3: number = int2.compare("42"); |
| 77 | + |
| 78 | +const negated: Integer = int3.negate(); |
| 79 | + |
| 80 | +const add1: Integer = int1.add(int2); |
| 81 | +const add2: Integer = int1.add(42); |
| 82 | +const add3: Integer = int1.add("42"); |
| 83 | + |
| 84 | +const subtract1: Integer = int1.subtract(int2); |
| 85 | +const subtract2: Integer = int1.subtract(42); |
| 86 | +const subtract3: Integer = int1.subtract("42"); |
| 87 | + |
| 88 | +const multiply1: Integer = int1.multiply(int2); |
| 89 | +const multiply2: Integer = int1.multiply(42); |
| 90 | +const multiply3: Integer = int1.multiply("42"); |
| 91 | + |
| 92 | +const div1: Integer = int1.div(int2); |
| 93 | +const div2: Integer = int1.div(42); |
| 94 | +const div3: Integer = int1.div("42"); |
| 95 | + |
| 96 | +const modulo1: Integer = int1.modulo(int2); |
| 97 | +const modulo2: Integer = int1.modulo(42); |
| 98 | +const modulo3: Integer = int1.modulo("42"); |
| 99 | + |
| 100 | +const not: Integer = int3.not(); |
| 101 | + |
| 102 | +const and1: Integer = int3.and(int2); |
| 103 | +const and2: Integer = int3.and(42); |
| 104 | +const and3: Integer = int3.and("42"); |
| 105 | + |
| 106 | +const or1: Integer = int3.or(int2); |
| 107 | +const or2: Integer = int3.or(42); |
| 108 | +const or3: Integer = int3.or("42"); |
| 109 | + |
| 110 | +const xor1: Integer = int3.xor(int2); |
| 111 | +const xor2: Integer = int3.xor(42); |
| 112 | +const xor3: Integer = int3.xor("42"); |
| 113 | + |
| 114 | +const shiftLeft: Integer = int2.shiftLeft(int1); |
| 115 | +const shiftRight: Integer = int2.shiftRight(int1); |
| 116 | + |
| 117 | +const isIntegerProp: boolean = Integer.__isInteger__; |
| 118 | +const isInteger: boolean = Integer.isInteger({}); |
| 119 | + |
| 120 | +const fromInt: Integer = Integer.fromInt(42); |
| 121 | +const fromNumber: Integer = Integer.fromNumber(42); |
| 122 | +const fromBits: Integer = Integer.fromBits(1, 2); |
| 123 | +const fromStr1: Integer = Integer.fromString("123"); |
| 124 | +const fromStr2: Integer = Integer.fromString("123", 10); |
| 125 | + |
| 126 | +const fromValue1: Integer = Integer.fromValue(int1); |
| 127 | +const fromValue2: Integer = Integer.fromValue(42); |
| 128 | +const fromValue3: Integer = Integer.fromValue("42"); |
| 129 | +const fromValue4: Integer = Integer.fromValue({low: 1, high: 2}); |
| 130 | + |
| 131 | +const toNumber1: number = Integer.toNumber(int3); |
| 132 | +const toNumber2: number = Integer.toNumber(42); |
| 133 | +const toNumber3: number = Integer.toNumber("42"); |
| 134 | +const toNumber4: number = Integer.toNumber({low: 2, high: 1}); |
| 135 | + |
| 136 | +const toStr1: string = Integer.toString(int3); |
| 137 | +const toStr2: string = Integer.toString(42); |
| 138 | +const toStr3: string = Integer.toString("42"); |
| 139 | +const toStr4: string = Integer.toString({low: 1, high: 1}); |
| 140 | + |
| 141 | +const toStr5: string = Integer.toString(int3, 10); |
| 142 | +const toStr6: string = Integer.toString(42, 2); |
| 143 | +const toStr7: string = Integer.toString("42", 16); |
| 144 | +const toStr8: string = Integer.toString({low: 1, high: 1}, 10); |
| 145 | + |
| 146 | +const inSafeRange1: boolean = Integer.inSafeRange(int3); |
| 147 | +const inSafeRange2: boolean = Integer.inSafeRange(42); |
| 148 | +const inSafeRange3: boolean = Integer.inSafeRange("42"); |
| 149 | +const inSafeRange4: boolean = Integer.inSafeRange({low: 2, high: 2}); |
| 150 | + |
| 151 | +const zero: Integer = Integer.ZERO; |
| 152 | +const one: Integer = Integer.ONE; |
| 153 | +const negOne: Integer = Integer.NEG_ONE; |
| 154 | +const max: Integer = Integer.MAX_VALUE; |
| 155 | +const min: Integer = Integer.MIN_VALUE; |
| 156 | +const minSafe: Integer = Integer.MIN_SAFE_VALUE; |
| 157 | +const maxSafe: Integer = Integer.MAX_SAFE_VALUE; |
| 158 | + |
| 159 | +const intFunc1: Integer = int(int1); |
| 160 | +const intFunc2: Integer = int(42); |
| 161 | +const intFunc3: Integer = int("42"); |
| 162 | +const intFunc4: Integer = int({low: 0, high: 1}); |
| 163 | + |
| 164 | +const isIntFunc: boolean = isInt({}); |
| 165 | + |
| 166 | +const inSafeRangeFunc1: boolean = inSafeRange(int2); |
| 167 | +const inSafeRangeFunc2: boolean = inSafeRange(42); |
| 168 | +const inSafeRangeFunc3: boolean = inSafeRange("42"); |
| 169 | +const inSafeRangeFunc4: boolean = inSafeRange({low: 1, high: 1}); |
| 170 | + |
| 171 | +const toNumberFunc1: number = toNumber(int3); |
| 172 | +const toNumberFunc2: number = toNumber(42); |
| 173 | +const toNumberFunc3: number = toNumber("42"); |
| 174 | +const toNumberFunc4: number = toNumber({low: 1, high: 1}); |
| 175 | + |
| 176 | +const toStringFunc1: string = toString(int3); |
| 177 | +const toStringFunc2: string = toString(42); |
| 178 | +const toStringFunc3: string = toString("42"); |
| 179 | +const toStringFunc4: string = toString({low: 1, high: 1}); |
| 180 | + |
| 181 | +const toStringFunc5: string = toString(int3, 2); |
| 182 | +const toStringFunc6: string = toString(42, 2); |
| 183 | +const toStringFunc7: string = toString("42", 10); |
| 184 | +const toStringFunc8: string = toString({low: 1, high: 1}, 16); |
0 commit comments