Browse Source

pastojs: test float constants

git-svn-id: trunk@38111 -
Mattias Gaertner 7 years ago
parent
commit
500c6c67f0
1 changed files with 46 additions and 2 deletions
  1. 46 2
      packages/pastojs/tests/tcmodules.pas

+ 46 - 2
packages/pastojs/tests/tcmodules.pas

@@ -4393,6 +4393,17 @@ begin
   'const',
   '  a = TDateTime(2.7);',
   '  b = a + TDateTime(1.7);',
+  '  c = 0.9 + 0.1;',
+  '  f0_1 = 0.1;',
+  '  f0_3 = 0.3;',
+  '  fn0_1 = -0.1;',
+  '  fn0_3 = -0.3;',
+  '  fn0_003 = -0.003;',
+  '  fn0_123456789 = -0.123456789;',
+  '  fn300_0 = -300.0;',
+  '  fn123456_0 = -123456.0;',
+  '  fn1234567_8 = -1234567.8;',
+  '  fn12345678_9 = -12345678.9;',
   'var',
   '  d: double = b;',
   'begin',
@@ -4404,13 +4415,35 @@ begin
   '  d:=10**3;',
   '  d:=10 mod 3;',
   '  d:=10 div 3;',
+  '  d:=c;',
+  '  d:=f0_1;',
+  '  d:=f0_3;',
+  '  d:=fn0_1;',
+  '  d:=fn0_3;',
+  '  d:=fn0_003;',
+  '  d:=fn0_123456789;',
+  '  d:=fn300_0;',
+  '  d:=fn123456_0;',
+  '  d:=fn1234567_8;',
+  '  d:=fn12345678_9;',
   '']);
   ConvertProgram;
   CheckSource('TestDouble',
     LinesToStr([
     'this.a = 2.7;',
-    'this.b = 2.7000000000000002E+000 + 1.7;',
-    'this.d = 4.4000000000000004E+000;'
+    'this.b = 2.7 + 1.7;',
+    'this.c = 0.9 + 0.1;',
+    'this.f0_1 = 0.1;',
+    'this.f0_3 = 0.3;',
+    'this.fn0_1 = -0.1;',
+    'this.fn0_3 = -0.3;',
+    'this.fn0_003 = -0.003;',
+    'this.fn0_123456789 = -0.123456789;',
+    'this.fn300_0 = -300.0;',
+    'this.fn123456_0 = -123456.0;',
+    'this.fn1234567_8 = -1234567.8;',
+    'this.fn12345678_9 = -12345678.9;',
+    'this.d = 4.4;'
     ]),
     LinesToStr([
     '$mod.d = 1.0;',
@@ -4421,6 +4454,17 @@ begin
     '$mod.d = Math.pow(10, 3);',
     '$mod.d = 10 % 3;',
     '$mod.d = Math.floor(10 / 3);',
+    '$mod.d = 1;',
+    '$mod.d = 0.1;',
+    '$mod.d = 0.3;',
+    '$mod.d = -0.1;',
+    '$mod.d = -0.3;',
+    '$mod.d = -0.003;',
+    '$mod.d = -0.123456789;',
+    '$mod.d = -300;',
+    '$mod.d = -123456;',
+    '$mod.d = -1234567.8;',
+    '$mod.d = -1.23456789E7;',
     '']));
 end;