diff options
author | svenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2020-05-03 15:08:31 +0000 |
---|---|---|
committer | svenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2020-05-03 15:08:31 +0000 |
commit | ae4aed7be6c6d1d836b67912d2de697ae38f48a9 (patch) | |
tree | dc74bd90e16351f3e16fe59f087a459c34294232 /tests/tbs | |
parent | 35d163c77e4fcda31c499bd6e11e3a38484a6747 (diff) | |
download | fpc-ae4aed7be6c6d1d836b67912d2de697ae38f48a9.tar.gz |
* handle generic parameters in Ord()
+ added test
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@45232 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'tests/tbs')
-rw-r--r-- | tests/tbs/tb0672.pp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/tbs/tb0672.pp b/tests/tbs/tb0672.pp new file mode 100644 index 0000000000..07ec08a599 --- /dev/null +++ b/tests/tbs/tb0672.pp @@ -0,0 +1,33 @@ +program tb0672; + +{$mode objfpc} + +type + generic TTest<T> = class + class function Test(aArg: T): LongInt; + end; + +class function TTest.Test(aArg: T): LongInt; +begin + Result := Ord(aArg); +end; + +type + TEnum = (teOne, teTwo, teThree); + + TTestBoolean = specialize TTest<Boolean>; + TTestChar = specialize TTest<Char>; + TTestWideChar = specialize TTest<WideChar>; + TTestEnum = specialize TTest<TEnum>; + +begin + if TTestBoolean.Test(True) <> Ord(True) then + Halt(1); + if TTestChar.Test(#42) <> Ord(#42) then + Halt(2); + if TTestWideChar.Test(#1234) <> Ord(#1234) then + Halt(3); + if TTestEnum.Test(teTwo) <> Ord(teTwo) then + Halt(4); + Writeln('ok'); +end. |