From d8079ea239dcb86811ceff4b1674b817f9c18106 Mon Sep 17 00:00:00 2001
From: "J. Gareth \"Curious Kit\" Moreton" <gareth@moreton-family.com>
Date: Fri, 29 Dec 2023 17:51:18 +0000
Subject: [PATCH]   * New "tval1" test to verify that Val with constants works
 properly

---
 tests/test/cg/tval1.pp | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 tests/test/cg/tval1.pp

diff --git a/tests/test/cg/tval1.pp b/tests/test/cg/tval1.pp
new file mode 100644
index 0000000000..d8bf0e797a
--- /dev/null
+++ b/tests/test/cg/tval1.pp
@@ -0,0 +1,32 @@
+{ %OPT=-O3 }
+
+{$mode objfpc}
+
+program tval1;
+
+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('Invalid', Output) then
+    Halt(1);
+
+  if not TryStrToInt('2', 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.
\ No newline at end of file