Skip to content

Commit fbaf8e5

Browse files
committed
Merge pull request #1740 from andre-nunes/math
Test missing parameter behavior
2 parents b589f06 + 0eb2871 commit fbaf8e5

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

Specs/Core/MathSpec.js

+60
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,22 @@ defineSuite([
7070
expect(CesiumMath.toRadians(360.0)).toEqual(2 * Math.PI);
7171
});
7272

73+
it('toRadians throws for undefined', function() {
74+
expect(function() {
75+
CesiumMath.toRadians();
76+
}).toThrowDeveloperError();
77+
});
78+
7379
it('toDegrees', function() {
7480
expect(CesiumMath.toDegrees(Math.PI)).toEqual(180.0);
7581
});
7682

83+
it('toDegrees throws for undefined', function() {
84+
expect(function() {
85+
CesiumMath.toDegrees();
86+
}).toThrowDeveloperError();
87+
});
88+
7789
it('convertLongitudeRange (1)', function() {
7890
expect(CesiumMath.convertLongitudeRange(CesiumMath.THREE_PI_OVER_TWO)).toEqualEpsilon(-CesiumMath.PI_OVER_TWO, CesiumMath.EPSILON16);
7991
});
@@ -86,6 +98,12 @@ defineSuite([
8698
expect(CesiumMath.convertLongitudeRange(Math.PI)).toEqualEpsilon(-Math.PI, CesiumMath.EPSILON16);
8799
});
88100

101+
it('convertLongitudeRange throws for undefined', function() {
102+
expect(function() {
103+
CesiumMath.convertLongitudeRange();
104+
}).toThrowDeveloperError();
105+
});
106+
89107
it('negativePiToPi positive', function() {
90108
expect(CesiumMath.negativePiToPi((Math.PI / 2) * Math.PI)).toEqualEpsilon((Math.PI / 2) * Math.PI - CesiumMath.TWO_PI, CesiumMath.EPSILON16);
91109
expect(CesiumMath.negativePiToPi(Math.PI / 0.5)).toEqualEpsilon(0.0, CesiumMath.EPSILON16);
@@ -103,6 +121,36 @@ defineSuite([
103121
expect(CesiumMath.negativePiToPi(-Math.PI + 1)).toEqualEpsilon(-Math.PI + 1, CesiumMath.EPSILON16);
104122
});
105123

124+
it('negativePiToPi throws for undefined', function() {
125+
expect(function() {
126+
CesiumMath.negativePiToPi();
127+
}).toThrowDeveloperError();
128+
});
129+
130+
it('zeroToTwoPi throws for undefined', function() {
131+
expect(function() {
132+
CesiumMath.zeroToTwoPi();
133+
}).toThrowDeveloperError();
134+
});
135+
136+
it('equalsEpsilon throws for undefined left', function() {
137+
expect(function() {
138+
CesiumMath.equalsEpsilon(undefined, 5.0, CesiumMath.EPSILON16);
139+
}).toThrowDeveloperError();
140+
});
141+
142+
it('equalsEpsilon throws for undefined right', function() {
143+
expect(function() {
144+
CesiumMath.equalsEpsilon(1.0, undefined, CesiumMath.EPSILON16);
145+
}).toThrowDeveloperError();
146+
});
147+
148+
it('equalsEpsilon throws for undefined', function() {
149+
expect(function() {
150+
CesiumMath.equalsEpsilon();
151+
}).toThrowDeveloperError();
152+
});
153+
106154
it('factorial produces the correct results', function() {
107155
var factorials = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000,
108156
121645100408832000, 2432902008176640000, 51090942171709440000, 1124000727777607680000, 25852016738884976640000, 620448401733239439360000];
@@ -118,6 +166,12 @@ defineSuite([
118166
expect(CesiumMath.incrementWrap(10, 10)).toEqual(0);
119167
});
120168

169+
it('incrementWrap throws for undefined', function() {
170+
expect(function() {
171+
CesiumMath.incrementWrap();
172+
}).toThrowDeveloperError();
173+
});
174+
121175
it('isPowerOfTwo finds powers of two', function() {
122176
expect(CesiumMath.isPowerOfTwo(1)).toEqual(true);
123177
expect(CesiumMath.isPowerOfTwo(2)).toEqual(true);
@@ -205,4 +259,10 @@ defineSuite([
205259
CesiumMath.nextPowerOfTwo();
206260
}).toThrowDeveloperError();
207261
});
262+
263+
it('clamp throws for undefined', function() {
264+
expect(function() {
265+
CesiumMath.clamp();
266+
}).toThrowDeveloperError();
267+
});
208268
});

0 commit comments

Comments
 (0)