Kaynağa Gözat

* Added new "tval2" test that assigns constant string symbol

J. Gareth "Curious Kit" Moreton 1 yıl önce
ebeveyn
işleme
e6d32f9f36
1 değiştirilmiş dosya ile 35 ekleme ve 0 silme
  1. 35 0
      tests/test/cg/tval2.pp

+ 35 - 0
tests/test/cg/tval2.pp

@@ -0,0 +1,35 @@
+{ %OPT=-O3 }
+
+{$mode objfpc}
+
+program tval2;
+
+const
+  SResStr = 'Invalid2';
+
+function TryStrToInt(const s: string; out i: Longint): boolean; inline;
+var
+  Error : word;
+begin
+  Val(s, i, Error);
+  TryStrToInt:=(Error=0)
+end;
+
+procedure DoTest;
+var
+  Output: Longint;
+begin
+  if TryStrToInt(SResStr, Output) then
+    Halt(1);
+
+  if not TryStrToInt(SResStr[8], Output) then
+    Halt(2);
+	
+  if Output <> 2 then
+    Halt(3);
+end;
+
+begin
+  DoTest(); { This is so "Output" is a local variable rather than global }
+  WriteLn('ok');
+end.