summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorruki <[email protected]>2021-09-02 18:16:11 +0800
committerGitHub <[email protected]>2021-09-02 18:16:11 +0800
commit20c34dcaf9ff92ecf08a1cec7e4d1be9836e6067 (patch)
tree69f67a0667475a27ad05178bfbe25746bc060bef /tests
parentce527abaa4e78b5d2d194512f875681e501794ac (diff)
parent767219ac1f3fb11f592d5a84b62cc2f199ab893a (diff)
Merge pull request #1629 from xmake-io/pascal
Add Pascal language support
Diffstat (limited to 'tests')
-rw-r--r--tests/projects/pascal/console/src/main.pas4
-rw-r--r--tests/projects/pascal/console/xmake.lua5
-rw-r--r--tests/projects/pascal/shared/src/foo.pas23
-rw-r--r--tests/projects/pascal/shared/src/main.pas14
-rw-r--r--tests/projects/pascal/shared/xmake.lua9
5 files changed, 55 insertions, 0 deletions
diff --git a/tests/projects/pascal/console/src/main.pas b/tests/projects/pascal/console/src/main.pas
new file mode 100644
index 000000000..a908ffab7
--- /dev/null
+++ b/tests/projects/pascal/console/src/main.pas
@@ -0,0 +1,4 @@
+program Hello;
+begin
+ writeln ('Hello, world.');
+end.
diff --git a/tests/projects/pascal/console/xmake.lua b/tests/projects/pascal/console/xmake.lua
new file mode 100644
index 000000000..32fd531a2
--- /dev/null
+++ b/tests/projects/pascal/console/xmake.lua
@@ -0,0 +1,5 @@
+add_rules("mode.debug", "mode.release")
+target("test")
+ set_kind("binary")
+ add_files("src/*.pas")
+
diff --git a/tests/projects/pascal/shared/src/foo.pas b/tests/projects/pascal/shared/src/foo.pas
new file mode 100644
index 000000000..d1952cf21
--- /dev/null
+++ b/tests/projects/pascal/shared/src/foo.pas
@@ -0,0 +1,23 @@
+library foo;
+
+function SubStr(CString: PChar;FromPos,ToPos: Longint): PChar; cdecl;
+
+var
+ Length: Integer;
+
+begin
+ Length := StrLen(CString);
+ SubStr := CString + Length;
+ if (FromPos > 0) and (ToPos >= FromPos) then
+ begin
+ if Length >= FromPos then
+ SubStr := CString + FromPos;
+ if Length > ToPos then
+ CString[ToPos+1] := #0;
+ end;
+end;
+
+exports
+ SubStr;
+
+end.
diff --git a/tests/projects/pascal/shared/src/main.pas b/tests/projects/pascal/shared/src/main.pas
new file mode 100644
index 000000000..ccf2e179b
--- /dev/null
+++ b/tests/projects/pascal/shared/src/main.pas
@@ -0,0 +1,14 @@
+uses strings;
+
+function SubStr(const CString: PChar; FromPos, ToPos: longint): PChar;
+ cdecl; external 'foo';
+
+var
+ s: PChar;
+ FromPos, ToPos: Integer;
+begin
+ s := strnew('TestMe');
+ FromPos := 2;
+ ToPos := 3;
+ WriteLn(SubStr(s, FromPos, ToPos));
+end.
diff --git a/tests/projects/pascal/shared/xmake.lua b/tests/projects/pascal/shared/xmake.lua
new file mode 100644
index 000000000..d96c29d5f
--- /dev/null
+++ b/tests/projects/pascal/shared/xmake.lua
@@ -0,0 +1,9 @@
+add_rules("mode.debug", "mode.release")
+target("foo")
+ set_kind("shared")
+ add_files("src/foo.pas")
+
+target("test")
+ set_kind("binary")
+ add_deps("foo")
+ add_files("src/main.pas")