Skip to content

Commit 968f4ac

Browse files
committed
test:cpu_arch parameter fun
1 parent e0b7a94 commit 968f4ac

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

+stdlib/+dotnet/cpu_arch.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function a = cpu_arch()
2+
a = string(System.Runtime.InteropServices.RuntimeInformation.OSArchitecture);
3+
% https://learn.microsoft.com/en-us/dotnet/core/compatibility/interop/7.0/osarchitecture-emulation
4+
end

+stdlib/+java/cpu_arch.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function a = cpu_arch()
2+
3+
a = string(javaMethod("getProperty", "java.lang.System", "os.arch"));
4+
5+
end

+stdlib/cpu_arch.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
function a = cpu_arch()
44

55
if stdlib.has_dotnet()
6-
a = System.Runtime.InteropServices.RuntimeInformation.OSArchitecture;
7-
% https://learn.microsoft.com/en-us/dotnet/core/compatibility/interop/7.0/osarchitecture-emulation
6+
a = stdlib.dotnet.cpu_arch();
87
elseif stdlib.has_java()
9-
a = javaMethod("getProperty", "java.lang.System", "os.arch");
8+
a = stdlib.java.cpu_arch();
109
else
1110
a = computer('arch');
1211
end

test/TestSys.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
properties (TestParameter)
88
fun = {stdlib.isoctave, stdlib.has_dotnet, ...
99
stdlib.has_java, stdlib.has_python}
10+
cpu_arch_fun = {@stdlib.cpu_arch, @stdlib.dotnet.cpu_arch, @stdlib.java.cpu_arch}
1011
ram_free_fun = {@stdlib.ram_free, @stdlib.sys.ram_free, @stdlib.java.ram_free, @stdlib.python.ram_free}
1112
ram_total_fun = {@stdlib.ram_total, @stdlib.sys.ram_total, @stdlib.dotnet.ram_total @stdlib.java.ram_total}
1213
end
@@ -103,9 +104,10 @@ function test_xcode_version(tc)
103104
end
104105

105106

106-
function test_cpu_arch(tc)
107+
function test_cpu_arch(tc, cpu_arch_fun)
108+
is_capable(tc, cpu_arch_fun)
107109

108-
arch = stdlib.cpu_arch();
110+
arch = cpu_arch_fun();
109111
tc.verifyGreaterThan(strlength(arch), 0, "CPU architecture should not be empty")
110112
end
111113

test/is_capable.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function is_capable(tc, f)
1212

1313
tc.assumeGreaterThan(dapi, 0)
1414

15-
if contains(n, "ram_total")
15+
if endsWith(n, "ram_total")
1616
tc.assumeGreaterThanOrEqual(dapi, 6);
1717
end
1818

0 commit comments

Comments
 (0)