Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | "use strict"; |
michael@0 | 4 | |
michael@0 | 5 | function test() { |
michael@0 | 6 | ok(isApprox(TiltMath.radians(30), 0.523598775), |
michael@0 | 7 | "The radians() function didn't calculate the value correctly."); |
michael@0 | 8 | |
michael@0 | 9 | ok(isApprox(TiltMath.degrees(0.5), 28.64788975), |
michael@0 | 10 | "The degrees() function didn't calculate the value correctly."); |
michael@0 | 11 | |
michael@0 | 12 | ok(isApprox(TiltMath.map(0.5, 0, 1, 0, 100), 50), |
michael@0 | 13 | "The map() function didn't calculate the value correctly."); |
michael@0 | 14 | |
michael@0 | 15 | is(TiltMath.isPowerOfTwo(32), true, |
michael@0 | 16 | "The isPowerOfTwo() function didn't return the expected value."); |
michael@0 | 17 | |
michael@0 | 18 | is(TiltMath.isPowerOfTwo(33), false, |
michael@0 | 19 | "The isPowerOfTwo() function didn't return the expected value."); |
michael@0 | 20 | |
michael@0 | 21 | ok(isApprox(TiltMath.nextPowerOfTwo(31), 32), |
michael@0 | 22 | "The nextPowerOfTwo() function didn't calculate the 1st value correctly."); |
michael@0 | 23 | |
michael@0 | 24 | ok(isApprox(TiltMath.nextPowerOfTwo(32), 32), |
michael@0 | 25 | "The nextPowerOfTwo() function didn't calculate the 2nd value correctly."); |
michael@0 | 26 | |
michael@0 | 27 | ok(isApprox(TiltMath.nextPowerOfTwo(33), 64), |
michael@0 | 28 | "The nextPowerOfTwo() function didn't calculate the 3rd value correctly."); |
michael@0 | 29 | |
michael@0 | 30 | ok(isApprox(TiltMath.clamp(5, 1, 3), 3), |
michael@0 | 31 | "The clamp() function didn't calculate the 1st value correctly."); |
michael@0 | 32 | |
michael@0 | 33 | ok(isApprox(TiltMath.clamp(5, 3, 1), 3), |
michael@0 | 34 | "The clamp() function didn't calculate the 2nd value correctly."); |
michael@0 | 35 | |
michael@0 | 36 | ok(isApprox(TiltMath.saturate(5), 1), |
michael@0 | 37 | "The saturate() function didn't calculate the 1st value correctly."); |
michael@0 | 38 | |
michael@0 | 39 | ok(isApprox(TiltMath.saturate(-5), 0), |
michael@0 | 40 | "The saturate() function didn't calculate the 2nd value correctly."); |
michael@0 | 41 | |
michael@0 | 42 | ok(isApproxVec(TiltMath.hex2rgba("#f00"), [1, 0, 0, 1]), |
michael@0 | 43 | "The hex2rgba() function didn't calculate the 1st rgba values correctly."); |
michael@0 | 44 | |
michael@0 | 45 | ok(isApproxVec(TiltMath.hex2rgba("#f008"), [1, 0, 0, 0.53]), |
michael@0 | 46 | "The hex2rgba() function didn't calculate the 2nd rgba values correctly."); |
michael@0 | 47 | |
michael@0 | 48 | ok(isApproxVec(TiltMath.hex2rgba("#ff0000"), [1, 0, 0, 1]), |
michael@0 | 49 | "The hex2rgba() function didn't calculate the 3rd rgba values correctly."); |
michael@0 | 50 | |
michael@0 | 51 | ok(isApproxVec(TiltMath.hex2rgba("#ff0000aa"), [1, 0, 0, 0.66]), |
michael@0 | 52 | "The hex2rgba() function didn't calculate the 4th rgba values correctly."); |
michael@0 | 53 | |
michael@0 | 54 | ok(isApproxVec(TiltMath.hex2rgba("rgba(255, 0, 0, 0.5)"), [1, 0, 0, 0.5]), |
michael@0 | 55 | "The hex2rgba() function didn't calculate the 5th rgba values correctly."); |
michael@0 | 56 | |
michael@0 | 57 | ok(isApproxVec(TiltMath.hex2rgba("rgb(255, 0, 0)"), [1, 0, 0, 1]), |
michael@0 | 58 | "The hex2rgba() function didn't calculate the 6th rgba values correctly."); |
michael@0 | 59 | } |