royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [royale-compiler] branch develop updated: fix tests for Flash
Date Tue, 03 Jul 2018 19:55:54 GMT
This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


The following commit(s) were added to refs/heads/develop by this push:
     new 01f9f88  fix tests for Flash
01f9f88 is described below

commit 01f9f88f28f47f9ca9a48ba982915c9a4b11c1ab
Author: Alex Harui <aharui@apache.org>
AuthorDate: Tue Jul 3 12:55:45 2018 -0700

    fix tests for Flash
---
 .../src/test/config/externc-config.xml             |  8 +++
 compiler/src/test/java/as/ASDateTests.java         | 60 +++++++++++++++++++---
 compiler/src/test/java/as/ASFeatureTestsBase.java  |  1 +
 ..._ASDateTests_ASDateTests_minutesUTC_swfdump.xml |  2 +-
 4 files changed, 63 insertions(+), 8 deletions(-)

diff --git a/compiler-externc/src/test/config/externc-config.xml b/compiler-externc/src/test/config/externc-config.xml
index eeb9804..ab2a1c0 100644
--- a/compiler-externc/src/test/config/externc-config.xml
+++ b/compiler-externc/src/test/config/externc-config.xml
@@ -139,5 +139,13 @@
         <class>Date</class>
         <name>timezoneOffset</name>
     </field-readonly>
+    <field-readonly>
+        <class>Date</class>
+        <name>day</name>
+    </field-readonly>
+    <field-readonly>
+        <class>Date</class>
+        <name>dayUTC</name>
+    </field-readonly>
 
 </royale-config>
diff --git a/compiler/src/test/java/as/ASDateTests.java b/compiler/src/test/java/as/ASDateTests.java
index 65b8d7e..4054b87 100644
--- a/compiler/src/test/java/as/ASDateTests.java
+++ b/compiler/src/test/java/as/ASDateTests.java
@@ -20,6 +20,8 @@
 package as;
 
 import org.junit.Test;
+import java.util.Date;
+import java.util.TimeZone;
 
 /**
  * Feature tests for AS Date objects
@@ -27,9 +29,35 @@ import org.junit.Test;
 public class ASDateTests extends ASFeatureTestsBase
 {
 
+    private String setTimeZone(String s)
+    {
+        TimeZone tz = TimeZone.getDefault();
+        System.out.println("tzoffset is " + new Integer(tz.getOffset(new Date().getTime())
/ 3600000).toString());
+        String offsetString = new Integer(tz.getOffset(new Date().getTime()) / 3600000).toString();
+        if (offsetString.length() == 2)
+            offsetString = offsetString.substring(0,1) + 0 + offsetString.substring(1, 2);
+        offsetString = "GMT" + offsetString + "00";
+        if (!hasFlashPlayerGlobal)
+            offsetString = "GMT-0800";
+        System.out.println("GMT is " + offsetString);
+        return s.replace("TZ", offsetString);
+    }
+    
+    private String setTimeZoneOffsetMinutes(String s)
+    {
+        TimeZone tz = TimeZone.getDefault();
+        System.out.println("tzoffset is " + new Integer(tz.getOffset(new Date().getTime())
/ 3600000).toString());
+        String offsetString = new Integer(tz.getOffset(new Date().getTime()) / -60000).toString();
+        if (!hasFlashPlayerGlobal)
+            offsetString = "-480";
+        System.out.println("offset in minutes is " + offsetString);
+        return s.replace("TZ", offsetString);
+    }
+    
     @Test
     public void ASDateTests_date()
     {
+        System.out.println("ASDateTests_date");
         String[] imports = new String[]
         {
         };
@@ -38,7 +66,7 @@ public class ASDateTests extends ASFeatureTestsBase
         };
         String[] testCode = new String[]
         {
-            "var date : Date = new Date('Sat Jun 30 23:59:59 GMT-0800 2018');",
+            setTimeZone("var date : Date = new Date('Sat Jun 30 23:59:59 TZ 2018');"),
             "date.date += 1;",
             "assertEqual('date.date', date.date, 1);",
         };
@@ -49,6 +77,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_dateUTC()
     {
+        System.out.println("ASDateTests_dateUTC");
         String[] imports = new String[]
         {
         };
@@ -68,6 +97,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_day()
     {
+        System.out.println("ASDateTests_day");
         String[] imports = new String[]
         {
         };
@@ -81,12 +111,13 @@ public class ASDateTests extends ASFeatureTestsBase
             "assertEqual('date.day', date.day, 0);",
         };
         String source = getAS(imports, declarations, testCode, new String[0]);
-        compileAndRun(source);
+        compileAndExpectErrors(source, false, false, false, null, "Property day is read-only.\n");
     }
 
     @Test
     public void ASDateTests_dayUTC()
     {
+        System.out.println("ASDateTests_dayUTC");
         String[] imports = new String[]
         {
         };
@@ -100,12 +131,13 @@ public class ASDateTests extends ASFeatureTestsBase
             "assertEqual('date.dayUTC', date.dayUTC, 1);",
         };
         String source = getAS(imports, declarations, testCode, new String[0]);
-        compileAndRun(source);
+        compileAndExpectErrors(source, false, false, false, null, "Property dayUTC is read-only.\n");
     }
 
     @Test
     public void ASDateTests_fullYear()
     {
+        System.out.println("ASDateTests_fullYear");
         String[] imports = new String[]
         {
         };
@@ -125,6 +157,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_fullYearUTC()
     {
+        System.out.println("ASDateTests_fullYearUTC");
         String[] imports = new String[]
         {
         };
@@ -144,6 +177,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_hours()
     {
+        System.out.println("ASDateTests_hours");
         String[] imports = new String[]
         {
         };
@@ -152,7 +186,7 @@ public class ASDateTests extends ASFeatureTestsBase
         };
         String[] testCode = new String[]
         {
-            "var date : Date = new Date('Sat Jun 30 23:59:59 GMT-0800 2018');",
+            setTimeZone("var date : Date = new Date('Sat Jun 30 23:59:59 TZ 2018');"),
             "date.hours += 1;",
             "assertEqual('date.hours', date.hours, 0);",
         };
@@ -163,6 +197,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_hoursUTC()
     {
+        System.out.println("ASDateTests_hoursUTC");
         String[] imports = new String[]
         {
         };
@@ -182,6 +217,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_milliseconds()
     {
+        System.out.println("ASDateTests_milliseconds");
         String[] imports = new String[]
         {
         };
@@ -201,6 +237,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_millisecondsUTC()
     {
+        System.out.println("ASDateTests_millisecondsUTC");
         String[] imports = new String[]
         {
         };
@@ -220,6 +257,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_minutes()
     {
+        System.out.println("ASDateTests_minutes");
         String[] imports = new String[]
         {
         };
@@ -239,6 +277,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_minutesUTC()
     {
+        System.out.println("ASDateTests_minutesUTC");
         String[] imports = new String[]
         {
         };
@@ -249,7 +288,7 @@ public class ASDateTests extends ASFeatureTestsBase
         {
             "var date : Date = new Date('Sat Jun 30 23:59:59 GMT-0800 2018');",
             "date.minutesUTC += 1;",
-            "assertEqual('date.minutesUTC', date.minutesUTC, 1);",
+            "assertEqual('date.minutesUTC', date.minutesUTC, 0);",
         };
         String source = getAS(imports, declarations, testCode, new String[0]);
         compileAndRun(source);
@@ -258,6 +297,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_month()
     {
+        System.out.println("ASDateTests_month");
         String[] imports = new String[]
         {
         };
@@ -266,7 +306,7 @@ public class ASDateTests extends ASFeatureTestsBase
         };
         String[] testCode = new String[]
         {
-            "var date : Date = new Date('Sat Jun 30 23:59:59 GMT-0800 2018');",
+            setTimeZone("var date : Date = new Date('Sat Jun 30 23:59:59 TZ 2018');"),
             "date.month += 1;",
             "assertEqual('date.month', date.month, 6);",
         };
@@ -277,6 +317,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_monthUTC()
     {
+        System.out.println("ASDateTests_monthUTC");
         String[] imports = new String[]
         {
         };
@@ -296,6 +337,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_seconds()
     {
+        System.out.println("ASDateTests_seconds");
         String[] imports = new String[]
         {
         };
@@ -315,6 +357,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_secondsUTC()
     {
+        System.out.println("ASDateTests_secondsUTC");
         String[] imports = new String[]
         {
         };
@@ -334,6 +377,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_time()
     {
+        System.out.println("ASDateTests_time");
         String[] imports = new String[]
         {
         };
@@ -353,6 +397,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_timezoneOffset_get()
     {
+        System.out.println("ASDateTests_timezoneOffset_get");
         String[] imports = new String[]
         {
         };
@@ -362,7 +407,7 @@ public class ASDateTests extends ASFeatureTestsBase
         String[] testCode = new String[]
         {
             "var date : Date = new Date('Sat Jun 30 23:59:59 GMT-0800 2018');",
-            "assertEqual('date.timezoneOffset', date.timezoneOffset, -480);",
+            setTimeZoneOffsetMinutes("assertEqual('date.timezoneOffset', date.timezoneOffset,
TZ);"),
         };
         String source = getAS(imports, declarations, testCode, new String[0]);
         compileAndRun(source);
@@ -371,6 +416,7 @@ public class ASDateTests extends ASFeatureTestsBase
     @Test
     public void ASDateTests_timezoneOffset_set()
     {
+        System.out.println("ASDateTests_timezoneOffset_set");
         String[] imports = new String[]
         {
         };
diff --git a/compiler/src/test/java/as/ASFeatureTestsBase.java b/compiler/src/test/java/as/ASFeatureTestsBase.java
index c66a58c..9a5cf71 100644
--- a/compiler/src/test/java/as/ASFeatureTestsBase.java
+++ b/compiler/src/test/java/as/ASFeatureTestsBase.java
@@ -123,6 +123,7 @@ public class ASFeatureTestsBase
         }
 
         List<String> args = new ArrayList<String>();
+        //args.add("-debug");
         if (hasFlashPlayerGlobal)
         	args.add("-external-library-path=" + testAdapter.getPlayerglobal().getPath());
         else {
diff --git a/compiler/src/test/resources/swfdumps/as_ASDateTests_ASDateTests_minutesUTC_swfdump.xml
b/compiler/src/test/resources/swfdumps/as_ASDateTests_ASDateTests_minutesUTC_swfdump.xml
index 7d4b86d..6d9dd5d 100644
--- a/compiler/src/test/resources/swfdumps/as_ASDateTests_ASDateTests_minutesUTC_swfdump.xml
+++ b/compiler/src/test/resources/swfdumps/as_ASDateTests_ASDateTests_minutesUTC_swfdump.xml
@@ -88,7 +88,7 @@ public class %0 extends Object
       15      pushstring      "date.minutesUTC"                       
       16      getlocal2                                               
       17      getproperty     minutesUTC                              
-      18      pushbyte                                             1  
+      18      pushbyte                                             0
       19      callpropvoid                                            
       20      returnvoid                                              
   }


Mime
View raw message