You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2019/05/04 21:15:27 UTC

[GitHub] [royale-asjs] greg-dove opened a new issue #421: Problems with certain Coercions and comparisons

greg-dove opened a new issue #421: Problems with certain Coercions and comparisons
URL: https://github.com/apache/royale-asjs/issues/421
 
 
   The following tests reveal 23 failing tests for coercion and comparisons
   
   ```
           [Test]
           public function testNullCoercion():void
           {
               var val:Object = null;
               
               var s:String = String(val);
               Assert.assertEquals('Unexpected coercion check', s, 'null'); //PASS
               var i:int = int(val);
               Assert.assertTrue('Unexpected coercion check', i === 0); //PASS
               var u:uint = uint(val);
               Assert.assertTrue('Unexpected coercion check', u === 0); //PASS
               var n:Number = Number(val);
               Assert.assertTrue('Unexpected coercion check', n === 0); //PASS
               var b:Boolean = Boolean(val);
               Assert.assertTrue('Unexpected coercion check', b === false); //PASS
               
               var t:TestClass1 = TestClass1(val);
               Assert.assertTrue('Unexpected coercion check', t === null); //PASS
               
               //with indirection
               var c:Class = String;
               var result:* = c(val);
               Assert.assertTrue('Unexpected coercion check', result === 'null'); //PASS
               c = int;
               result = c(val);
               Assert.assertTrue('Unexpected coercion check', result === 0);//FAIL
               c = uint;
               result = c(val);
               Assert.assertTrue('Unexpected coercion check', result === 0);//FAIL
               c = Number;
               result = c(val);
               Assert.assertTrue('Unexpected coercion check', result === 0); //FAIL
               
               c = Boolean;
               result = c(val);
               Assert.assertTrue('Unexpected coercion check', result === false);//PASS
               
               c = TestClass1;
               result = c(val);
               Assert.assertTrue('Unexpected coercion check', result === null);//FAIL
           }
           
           [Test]
           public function testObjectCoercion():void
           {
               Assert.assertTrue('Unexpected null check', Object(undefined) != null);//PASS
               Assert.assertTrue('Unexpected null check', Object(null) != null);//PASS
               Assert.assertTrue('Unexpected null check', Object('test') === 'test');//FAIL
               Assert.assertTrue('Unexpected null check', Object(1) === 1);//FAIL
               Assert.assertTrue('Unexpected null check', Object(false) === false);//FAIL
               Assert.assertTrue('Unexpected null check', Object(true) === true);//FAIL
               var indirection:* = undefined;
               Assert.assertTrue('Unexpected null check', Object(indirection) != null);//PASS
               indirection = null;
               Assert.assertTrue('Unexpected null check', Object(indirection) != null);//PASS
               indirection = 'test';
               Assert.assertTrue('Unexpected null check', Object(indirection) === 'test');//FAIL
               indirection = 1;
               Assert.assertTrue('Unexpected null check', Object(indirection) === 1);//FAIL
               indirection = false;
               Assert.assertTrue('Unexpected null check', Object(indirection) === false);//FAIL
               indirection = true;
               Assert.assertTrue('Unexpected null check', Object(indirection) === true);//FAIL
               var dynObjectClass:Class = Object;
               //regular indirect coercion
               indirection = undefined;
               Assert.assertTrue('Unexpected null check', dynObjectClass(indirection) != null);//PASS
               indirection = null;
               Assert.assertTrue('Unexpected null check', dynObjectClass(indirection) != null);//PASS
               indirection = 'test';
               Assert.assertTrue('Unexpected null check', dynObjectClass(indirection) === 'test');//FAIL
               indirection = 1;
               Assert.assertTrue('Unexpected null check', dynObjectClass(indirection) === 1);//FAIL
               indirection = false;
               Assert.assertTrue('Unexpected null check', dynObjectClass(indirection) === false);//FAIL
               indirection = true;
               Assert.assertTrue('Unexpected null check', dynObjectClass(indirection) === true);//FAIL
               //no need to test 'new Object(something)' as it is not permitted explicitly in actionscript
               //but it can be achieved via indirection:
               var dynObject:Class = Object;
               indirection = undefined;
               Assert.assertTrue('Unexpected null check', new dynObject(indirection) != null);//PASS
               indirection = null;
               Assert.assertTrue('Unexpected null check', new dynObject(indirection) != null);//PASS
               indirection = 'test';
               Assert.assertTrue('Unexpected null check', new dynObject(indirection) === 'test');//FAIL
               indirection = 1;
               Assert.assertTrue('Unexpected null check', new dynObject(indirection) === 1);//FAIL
               indirection = false;
               Assert.assertTrue('Unexpected null check', new dynObject(indirection) === false);//FAIL
               indirection = true;
               Assert.assertTrue('Unexpected null check', new dynObject(indirection) === true);//FAIL
               
           }
           
           [Test]
           public function testImplicitCoercion():void
           {
               var testclass2Class:Class = TestClass2;
               var testClass3:TestClass3;
               var caughtError:Boolean;
               try
               {
                   caughtError = false;
                   testClass3 = new testclass2Class();
               } catch (e:Error)
               {
                   caughtError = e is TypeError
               }
               
               Assert.assertTrue('Unexpected coercion check', caughtError); //FAIL
               Assert.assertTrue('Unexpected coercion check', testClass3 == null); //FAIL
           }
           
           [Test]
           public function testString():void
           {
               Assert.assertTrue('Unexpected string check', String('test') == 'test'); //PASS
               Assert.assertTrue('Unexpected string check', String('test') === 'test'); //PASS
               Assert.assertTrue('Unexpected string check', new String('test') == 'test'); //PASS
               Assert.assertTrue('Unexpected string check', new String('test') === 'test'); //FAIL
           }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services