Skip to content

Commit aa02012

Browse files
committed
Fix name ambiguity issue with AIR 3.0
1 parent f2bba4e commit aa02012

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

tests/src/com/adobe/serialization/json/JSONTest.as

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ package com.adobe.serialization.json
5252

5353
try
5454
{
55-
var o:* = JSON.decode( jsonString, strict );
55+
var o:* = com.adobe.serialization.json.JSON.decode( jsonString, strict );
5656
fail( "Expecting parse error but one was not thrown" );
5757
}
5858
catch ( e:JSONParseError )
@@ -73,28 +73,28 @@ package com.adobe.serialization.json
7373
*/
7474
public function testDecodeTrue():void
7575
{
76-
var o:* = JSON.decode( "true" ) as Boolean;
76+
var o:* = com.adobe.serialization.json.JSON.decode( "true" ) as Boolean;
7777
assertTrue( "Expected decoded true", o );
7878
}
7979

8080
public function testDecodeFalse():void
8181
{
82-
var o:* = JSON.decode( "false" ) as Boolean;
82+
var o:* = com.adobe.serialization.json.JSON.decode( "false" ) as Boolean;
8383
assertFalse( "Expected decoded false", o );
8484
}
8585

8686
public function testDecodeNull():void
8787
{
88-
var o:* = JSON.decode( "null " );
88+
var o:* = com.adobe.serialization.json.JSON.decode( "null " );
8989
assertNull( "Expected decoded null", o );
9090
}
9191

9292
public function testDecodeString():void
9393
{
9494
var string:String = "this \"is\" \t a \/ string \b \f \r \h \\ \n with \' ch\\u0061rs that should be { } http://escaped.com/";
95-
assertEquals( string, JSON.decode( JSON.encode( string ) ) );
95+
assertEquals( string, com.adobe.serialization.json.JSON.decode( com.adobe.serialization.json.JSON.encode( string ) ) );
9696

97-
var o:String = JSON.decode( "\"http:\/\/digg.com\/security\/Simple_Digg_Hack\"" ) as String;
97+
var o:String = com.adobe.serialization.json.JSON.decode( "\"http:\/\/digg.com\/security\/Simple_Digg_Hack\"" ) as String;
9898
assertEquals( "String not decoded correctly", "http://digg.com/security/Simple_Digg_Hack", o );
9999

100100
expectParseError( "\"unterminated string" );
@@ -112,7 +112,7 @@ package com.adobe.serialization.json
112112
expectParseError( "\"\\u123\"" );
113113

114114
// Unicode decodes correctly
115-
assertEquals( "a", JSON.decode( "\"\\u0061\"" ) );
115+
assertEquals( "a", com.adobe.serialization.json.JSON.decode( "\"\\u0061\"" ) );
116116
}
117117

118118
// Issue #104 - http://code.google.com/p/as3corelib/issues/detail?id=104
@@ -132,13 +132,13 @@ package com.adobe.serialization.json
132132
{
133133
var string:String = "control char " + i + ": " + String.fromCharCode( i ) + ""
134134
assertEquals( string,
135-
JSON.decode( "\"" + string + "\"", false ) );
135+
com.adobe.serialization.json.JSON.decode( "\"" + string + "\"", false ) );
136136
}
137137
}
138138

139139
public function testDecodeZero():void
140140
{
141-
var n:Number = JSON.decode( "0" ) as Number;
141+
var n:Number = com.adobe.serialization.json.JSON.decode( "0" ) as Number;
142142
assertEquals( n, 0 );
143143
}
144144

@@ -149,25 +149,25 @@ package com.adobe.serialization.json
149149

150150
public function testDecodePositiveInt():void
151151
{
152-
var n:int = JSON.decode( "123871" ) as int;
152+
var n:int = com.adobe.serialization.json.JSON.decode( "123871" ) as int;
153153
assertEquals( n, 123871 );
154154
}
155155

156156
public function testDecodeNegativeInt():void
157157
{
158-
var n:int = JSON.decode( "-97123" ) as int;
158+
var n:int = com.adobe.serialization.json.JSON.decode( "-97123" ) as int;
159159
assertEquals( n, -97123 );
160160
}
161161

162162
public function testDecodePositiveFloat():void
163163
{
164-
var n:Number = JSON.decode( "12.987324" ) as Number;
164+
var n:Number = com.adobe.serialization.json.JSON.decode( "12.987324" ) as Number;
165165
assertEquals( n, 12.987324 );
166166
}
167167

168168
public function testDecodeNegativeFloat():void
169169
{
170-
var n:Number = JSON.decode( "-1298.7324" ) as Number;
170+
var n:Number = com.adobe.serialization.json.JSON.decode( "-1298.7324" ) as Number;
171171
assertEquals( n, -1298.7324 );
172172
}
173173

@@ -183,32 +183,32 @@ package com.adobe.serialization.json
183183

184184
public function testDecodeScientificRegularExponent():void
185185
{
186-
var n:Number = JSON.decode( "6.02e2" ) as Number;
186+
var n:Number = com.adobe.serialization.json.JSON.decode( "6.02e2" ) as Number;
187187
assertEquals( n, 602 );
188188

189-
n = JSON.decode( "-2e10" );
189+
n = com.adobe.serialization.json.JSON.decode( "-2e10" );
190190
assertEquals( n, -20000000000 );
191191
assertEquals( n, -2 * Math.pow( 10, 10 ) );
192192
}
193193

194194
public function testDecodeScientificPositiveExponent():void
195195
{
196-
var n:Number = JSON.decode( "2E+9" ) as Number;
196+
var n:Number = com.adobe.serialization.json.JSON.decode( "2E+9" ) as Number;
197197
assertEquals( n, 2 * Math.pow( 10, 9 ) );
198198

199-
n = JSON.decode( "-2.2E+23" ) as Number;
199+
n = com.adobe.serialization.json.JSON.decode( "-2.2E+23" ) as Number;
200200
assertEquals( n, -2.2 * Math.pow( 10, 23 ) );
201201
}
202202

203203
public function testDecodeScientificNegativeExponent():void
204204
{
205-
var n:Number = JSON.decode( "6.02e-23" ) as Number;
205+
var n:Number = com.adobe.serialization.json.JSON.decode( "6.02e-23" ) as Number;
206206
assertEquals( n, 6.02 * Math.pow( 10, -23 ) );
207207

208-
n = JSON.decode( "-4e-9" ) as Number;
208+
n = com.adobe.serialization.json.JSON.decode( "-4e-9" ) as Number;
209209
assertEquals( n, -4 * Math.pow( 10, -9 ) );
210210

211-
n = JSON.decode( "0E-2" ) as Number;
211+
n = com.adobe.serialization.json.JSON.decode( "0E-2" ) as Number;
212212
assertEquals( n, 0 );
213213
}
214214

@@ -222,7 +222,7 @@ package com.adobe.serialization.json
222222
*/
223223
public function testDecodeHex():void
224224
{
225-
var n:Number = JSON.decode( "0xFF0033", false );
225+
var n:Number = com.adobe.serialization.json.JSON.decode( "0xFF0033", false );
226226
assertEquals( 0xFF0033, n );
227227

228228
// Verify invalid hex format throws error
@@ -241,10 +241,10 @@ package com.adobe.serialization.json
241241
*/
242242
public function testDecodeNaN():void
243243
{
244-
var n:Number = JSON.decode( "NaN", false ) as Number;
244+
var n:Number = com.adobe.serialization.json.JSON.decode( "NaN", false ) as Number;
245245
assertTrue( isNaN( n ) );
246246

247-
var o:Object = JSON.decode( "{ \"num\": NaN }", false );
247+
var o:Object = com.adobe.serialization.json.JSON.decode( "{ \"num\": NaN }", false );
248248
assertNotNull( o );
249249
assertTrue( isNaN( o.num ) );
250250

@@ -255,7 +255,7 @@ package com.adobe.serialization.json
255255

256256
public function testDecodeObject():void
257257
{
258-
var o:* = JSON.decode( " { \"test\": true, \"test2\": -12356732.12 } " ) as Object;
258+
var o:* = com.adobe.serialization.json.JSON.decode( " { \"test\": true, \"test2\": -12356732.12 } " ) as Object;
259259
assertNotNull( o );
260260

261261
assertEquals( "Expected decoded object.test = true", true, o.test );
@@ -268,12 +268,12 @@ package com.adobe.serialization.json
268268
*/
269269
public function testDecodeObjectWithTrailingComma():void
270270
{
271-
var o:Object = JSON.decode( "{\"p1\":true,\"p2\":false,}", false );
271+
var o:Object = com.adobe.serialization.json.JSON.decode( "{\"p1\":true,\"p2\":false,}", false );
272272
assertNotNull( o );
273273
assertTrue( o.p1 );
274274
assertFalse( o.p2 );
275275

276-
o = JSON.decode( "{,}", false );
276+
o = com.adobe.serialization.json.JSON.decode( "{,}", false );
277277
assertNotNull( o );
278278

279279
// Verify strict mode throws error with trailing comma
@@ -291,7 +291,7 @@ package com.adobe.serialization.json
291291

292292
public function testDecodeArray():void
293293
{
294-
var o:* = JSON.decode( " [ null, true, false, 100, -100, \"test\", { \"foo\": \"bar\" } ] " ) as Array;
294+
var o:* = com.adobe.serialization.json.JSON.decode( " [ null, true, false, 100, -100, \"test\", { \"foo\": \"bar\" } ] " ) as Array;
295295
assertNull( "Expected decoded array[0] == null", o[0] );
296296
assertTrue( "Expected decoded array[1] == true", o[1] );
297297
assertFalse( "Expected decoded array[2] == false", o[2] );
@@ -303,7 +303,7 @@ package com.adobe.serialization.json
303303

304304
public function testDecodeArrayWithNewlines():void
305305
{
306-
var o:Array = JSON.decode( "\n [ \nnull, \n \r \t \r true \n ] \r \t \r \n" ) as Array;
306+
var o:Array = com.adobe.serialization.json.JSON.decode( "\n [ \nnull, \n \r \t \r true \n ] \r \t \r \n" ) as Array;
307307

308308
assertNull( "Expected decoded with newlines array[0] == null", o[0] );
309309
assertTrue( "Expected decoded with newlines array[1] == true", o[1] );
@@ -315,11 +315,11 @@ package com.adobe.serialization.json
315315
*/
316316
public function testDecodeArrayWithTrailingComma():void
317317
{
318-
var o:Array = JSON.decode( "[0,1,]", false ) as Array;
318+
var o:Array = com.adobe.serialization.json.JSON.decode( "[0,1,]", false ) as Array;
319319
assertEquals( 0, o[0] );
320320
assertEquals( 1, o[1] );
321321

322-
o = JSON.decode( "[,]", false ) as Array;
322+
o = com.adobe.serialization.json.JSON.decode( "[,]", false ) as Array;
323323
assertNotNull( o );
324324
assertEquals( 0, o.length );
325325

@@ -342,10 +342,10 @@ package com.adobe.serialization.json
342342
expectParseError( "/*/" );
343343
expectParseError( "//" );
344344

345-
var n:Number = JSON.decode( "// this is a number\n12" );
345+
var n:Number = com.adobe.serialization.json.JSON.decode( "// this is a number\n12" );
346346
assertEquals( 12, n );
347347

348-
n = JSON.decode( "/* \n\n multiine com//ment *///\n14" );
348+
n = com.adobe.serialization.json.JSON.decode( "/* \n\n multiine com//ment *///\n14" );
349349
assertEquals( 14, n )
350350
}
351351

@@ -354,7 +354,7 @@ package com.adobe.serialization.json
354354
var jsonString:String = " // test comment"
355355
+ "\n // test comment line 2"
356356
+ "\nfalse";
357-
var o:* = JSON.decode( jsonString );
357+
var o:* = com.adobe.serialization.json.JSON.decode( jsonString );
358358
assertEquals( false, o );
359359
}
360360

@@ -368,24 +368,24 @@ package com.adobe.serialization.json
368368
var n:Number;
369369
var nbsp:String = String.fromCharCode( 160 ); // non-breaking space
370370

371-
n = JSON.decode( " 1 " );
371+
n = com.adobe.serialization.json.JSON.decode( " 1 " );
372372
assertEquals( 1, n );
373373

374-
n = JSON.decode( "\t2\t" );
374+
n = com.adobe.serialization.json.JSON.decode( "\t2\t" );
375375
assertEquals( 2, n );
376376

377-
n = JSON.decode( "\r3\r" );
377+
n = com.adobe.serialization.json.JSON.decode( "\r3\r" );
378378
assertEquals( 3, n );
379379

380-
n = JSON.decode( "\n4\n" );
380+
n = com.adobe.serialization.json.JSON.decode( "\n4\n" );
381381
assertEquals( 4, n );
382382

383383
// Verify combined before/after spacing
384-
n = JSON.decode( "\t \n\n\r \r\n\t 100 \r\n\t\r\r\r\n \n" ) as Number
384+
n = com.adobe.serialization.json.JSON.decode( "\t \n\n\r \r\n\t 100 \r\n\t\r\r\r\n \n" ) as Number
385385
assertEquals( 100, n );
386386

387387
// In non-strict mode, we should also accept non breaking space
388-
n = JSON.decode( "\t \n"
388+
n = com.adobe.serialization.json.JSON.decode( "\t \n"
389389
+ nbsp
390390
+ "\n\r \r\n\t 100 \r\n\t\r\r\r\n"
391391
+ nbsp
@@ -404,13 +404,13 @@ package com.adobe.serialization.json
404404
expectParseError( "true Z" );
405405

406406
// non-strict mode will not throw errors
407-
var a:Array = JSON.decode( "[ 1 ] true", false ) as Array;
407+
var a:Array = com.adobe.serialization.json.JSON.decode( "[ 1 ] true", false ) as Array;
408408
assertEquals( 1, a[0] );
409409

410-
var n:Number = JSON.decode( "1Z", false ) as Number;
410+
var n:Number = com.adobe.serialization.json.JSON.decode( "1Z", false ) as Number;
411411
assertEquals( 1, n );
412412

413-
var b:Boolean = JSON.decode( "true Z", false ) as Boolean;
413+
var b:Boolean = com.adobe.serialization.json.JSON.decode( "true Z", false ) as Boolean;
414414
assertTrue( b );
415415
}
416416

@@ -434,46 +434,46 @@ package com.adobe.serialization.json
434434

435435
public function testEncodeTrue():void
436436
{
437-
var o:String = JSON.encode( true );
437+
var o:String = com.adobe.serialization.json.JSON.encode( true );
438438
assertEquals( "Expected encoded true", "true", o );
439439
}
440440

441441
public function testEncodeFalse():void
442442
{
443-
var o:String = JSON.encode( false );
443+
var o:String = com.adobe.serialization.json.JSON.encode( false );
444444
assertEquals( "Expected encoded false", "false", o );
445445
}
446446

447447
public function testEncodeNull():void
448448
{
449-
var o:String = JSON.encode( null );
449+
var o:String = com.adobe.serialization.json.JSON.encode( null );
450450
assertEquals( "Expected encoded null", "null", o );
451451
}
452452

453453
public function testEncodeString():void
454454
{
455-
var o:String = JSON.encode( "this is a \n \"string\"" );
455+
var o:String = com.adobe.serialization.json.JSON.encode( "this is a \n \"string\"" );
456456
assertEquals( "Expected encoded string", "\"this is a \\n \\\"string\\\"\"", o );
457457

458-
o = JSON.encode( "myString" );
458+
o = com.adobe.serialization.json.JSON.encode( "myString" );
459459
assertEquals( "\"myString\"", o );
460460
}
461461

462462
public function testEncodeArrayEmpty():void
463463
{
464-
var o:String = JSON.encode( [] );
464+
var o:String = com.adobe.serialization.json.JSON.encode( [] );
465465
assertEquals( "Expected encoded []", "[]", o );
466466
}
467467

468468
public function testEncodeArray():void
469469
{
470-
var o:String = JSON.encode( [ true, false, -10, null, Number.NEGATIVE_INFINITY ] );
470+
var o:String = com.adobe.serialization.json.JSON.encode( [ true, false, -10, null, Number.NEGATIVE_INFINITY ] );
471471
assertTrue( "Expected encoded array", "[true,false,-10,null,null]", o );
472472
}
473473

474474
public function testEncodeObjectEmpty():void
475475
{
476-
var o:String = JSON.encode( {} );
476+
var o:String = com.adobe.serialization.json.JSON.encode( {} );
477477
assertTrue( "Expected encoded {}", "{}", o );
478478
}
479479

@@ -492,12 +492,12 @@ package com.adobe.serialization.json
492492
//assertTrue( "Expected encoded object", o == "{\"test1\":true,\"test 2\":false,\" test _3\":{\"foo\":\"bar\"}}" );
493493

494494
var obj:Object = { foo: { foo2: { foo3: { foo4: "bar" } } } };
495-
var s:String = JSON.encode( obj );
495+
var s:String = com.adobe.serialization.json.JSON.encode( obj );
496496
assertEquals( "Deeply nested", "{\"foo\":{\"foo2\":{\"foo3\":{\"foo4\":\"bar\"}}}}", s );
497497

498498
obj = new Object();
499499
obj[" prop with spaces "] = true;
500-
s = JSON.encode( obj );
500+
s = com.adobe.serialization.json.JSON.encode( obj );
501501
assertEquals( "Prop with spaces", "{\" prop with spaces \":true}", s );
502502
}
503503

@@ -506,14 +506,14 @@ package com.adobe.serialization.json
506506
var customObject:SimpleClass = new SimpleClass();
507507
customObject.transientVar = "Should not be encoded";
508508

509-
var s:String = JSON.encode( customObject );
509+
var s:String = com.adobe.serialization.json.JSON.encode( customObject );
510510

511511
assertTrue( "Has length", s.length > 0 );
512512
// Make sure the transient variable was not encoded
513513
assertEquals( "Should not find transient var in string", -1, s.indexOf( "\"transientVar\":\"Should not be encoded\"" ) );
514514

515515
// Decode the string so we can verify that it has the properties
516-
var o:Object = JSON.decode( s );
516+
var o:Object = com.adobe.serialization.json.JSON.decode( s );
517517

518518
assertNotNull( o );
519519
assertNotNull( o.publicVar1 );

0 commit comments

Comments
 (0)