|
1 | | -function expectError(expectedError, fn) { |
2 | | - try { |
3 | | - fn(); |
4 | | - fail('Expected error but none thrown'); |
5 | | - } catch (e) { |
6 | | - // throw again the exception thorwned by 'fail' above |
7 | | - if (e instanceof JsUnitException) throw e; |
8 | | - |
9 | | - // throwned class and message should be as expected |
10 | | - assertEquals(expectedError.name, e.name); |
11 | | - assertEquals(expectedError.message, e.message) |
12 | | - } |
13 | | -} |
14 | | - |
15 | 1 | function testSchemaXSDString() { |
16 | 2 | var t = Jsonix.Schema.XSD.String.INSTANCE; |
17 | 3 | assertEquals('test', t.print('test')); |
@@ -205,48 +191,6 @@ function testSchemaXSDCalendar() { |
205 | 191 |
|
206 | 192 | } |
207 | 193 |
|
208 | | -function testSchemaXSDCalendarError() { |
209 | | - expectError( |
210 | | - new Error('Value [nomatch] does not match xs:dateTime, xs:date, xs:time, xs:gYearMonth, xs:gYear, xs:gMonthDay, xs:gMonth or xs:gDay patterns.'), |
211 | | - function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parse('nomatch') }); |
212 | | - |
213 | | - expectError( |
214 | | - new Error('Value [201002] does not match the xs:gYearMonth pattern.'), |
215 | | - function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGYearMonth('201002'); }); |
216 | | - |
217 | | - expectError( |
218 | | - new Error('Value [10] does not match the xs:gYear pattern.'), |
219 | | - function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGYear('10'); }); |
220 | | - |
221 | | - expectError( |
222 | | - new Error('Value [02-10] does not match the xs:gMonthDay pattern.'), |
223 | | - function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGMonthDay('02-10'); }); |
224 | | - |
225 | | - expectError( |
226 | | - new Error('Value [02] does not match the xs:gMonth pattern.'), |
227 | | - function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGMonth('02'); }); |
228 | | - |
229 | | - expectError( |
230 | | - new Error('Value [01] does not match the xs:gDay pattern.'), |
231 | | - function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGDay('01'); }); |
232 | | - |
233 | | - expectError( |
234 | | - new Error('Value [2010-02-01 12:23:0] does not match the xs:date pattern.'), |
235 | | - function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseDateTime('2010-02-01 12:23:0'); }); |
236 | | - |
237 | | - expectError( |
238 | | - new Error('Value [20100201] does not match the xs:date pattern.'), |
239 | | - function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseDate('20100201') }); |
240 | | - |
241 | | - expectError( |
242 | | - new Error('Value [12:23:0] does not match the xs:time pattern.'), |
243 | | - function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseTime('12:23:0'); }); |
244 | | - |
245 | | - expectError( |
246 | | - new Error('Value [PDT] does not match the timezone pattern.'), |
247 | | - function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseTimezoneString('PDT'); }); |
248 | | -} |
249 | | - |
250 | 194 | function testSchemaXSDTime() { |
251 | 195 | var t0 = Jsonix.Schema.XSD.TimeAsDate.INSTANCE.parse('10:00:00.5'); |
252 | 196 | var time0 = new Date(1970, 0, 1, 10, 0, 0); |
|
0 commit comments