summaryrefslogtreecommitdiff
path: root/tests/diagnostics
diff options
context:
space:
mode:
Diffstat (limited to 'tests/diagnostics')
-rw-r--r--tests/diagnostics/extension-visibility-a.slang12
-rw-r--r--tests/diagnostics/extension-visibility-b.slang4
-rw-r--r--tests/diagnostics/extension-visibility-c.slang2
-rw-r--r--tests/diagnostics/extension-visibility.slang.expected6
-rw-r--r--tests/diagnostics/internal-visibility/that-module-impl.slang17
-rw-r--r--tests/diagnostics/internal-visibility/that-module.slang25
-rw-r--r--tests/diagnostics/internal-visibility/this-module.slang26
-rw-r--r--tests/diagnostics/private-visibility.slang44
-rw-r--r--tests/diagnostics/visibility.slang23
9 files changed, 147 insertions, 12 deletions
diff --git a/tests/diagnostics/extension-visibility-a.slang b/tests/diagnostics/extension-visibility-a.slang
index 97e4ef85c..162320d51 100644
--- a/tests/diagnostics/extension-visibility-a.slang
+++ b/tests/diagnostics/extension-visibility-a.slang
@@ -1,17 +1,17 @@
// extension-visibility-a.slang
-interface IThing
+public interface IThing
{
- int getValue();
+ public int getValue();
}
// Note: not implementing the interface here!
-struct MyThing
+public struct MyThing
{
- int value;
+ public int value;
}
-int helper<T : IThing>(T thing)
+public int helper<T : IThing>(T thing)
{
return thing.getValue();
-} \ No newline at end of file
+}
diff --git a/tests/diagnostics/extension-visibility-b.slang b/tests/diagnostics/extension-visibility-b.slang
index 7848f2a56..dbefe66e7 100644
--- a/tests/diagnostics/extension-visibility-b.slang
+++ b/tests/diagnostics/extension-visibility-b.slang
@@ -2,7 +2,7 @@
import extension_visibility_a;
-extension MyThing : IThing
+public extension MyThing : IThing
{
- int getValue() { return value; }
+ public int getValue() { return value; }
}
diff --git a/tests/diagnostics/extension-visibility-c.slang b/tests/diagnostics/extension-visibility-c.slang
index 2d7a5224d..71680b31e 100644
--- a/tests/diagnostics/extension-visibility-c.slang
+++ b/tests/diagnostics/extension-visibility-c.slang
@@ -3,7 +3,7 @@
import extension_visibility_a;
import extension_visibility_b;
-int works(MyThing thing)
+public int works(MyThing thing)
{
return helper(thing);
}
diff --git a/tests/diagnostics/extension-visibility.slang.expected b/tests/diagnostics/extension-visibility.slang.expected
index 732ff4189..eed86715d 100644
--- a/tests/diagnostics/extension-visibility.slang.expected
+++ b/tests/diagnostics/extension-visibility.slang.expected
@@ -3,9 +3,9 @@ standard error = {
tests/diagnostics/extension-visibility.slang(17): error 39999: could not specialize generic for arguments of type (MyThing)
return helper(thing);
^
-tests/diagnostics/extension-visibility-a.slang(14): note 39999: see declaration of func helper<T>(T) -> int
-int helper<T : IThing>(T thing)
- ^~~~~~
+tests/diagnostics/extension-visibility-a.slang(14): note 39999: see declaration of public func helper<T>(T) -> int
+public int helper<T : IThing>(T thing)
+ ^~~~~~
}
standard output = {
}
diff --git a/tests/diagnostics/internal-visibility/that-module-impl.slang b/tests/diagnostics/internal-visibility/that-module-impl.slang
new file mode 100644
index 000000000..893510afe
--- /dev/null
+++ b/tests/diagnostics/internal-visibility/that-module-impl.slang
@@ -0,0 +1,17 @@
+implementing "that-module";
+
+
+public void publicFunc2() { }
+
+internal void internalFunc1() {}
+
+public struct PublicStruct
+{
+ int x;
+ public int y;
+}
+
+public namespace Namespace
+{
+ public static int publicVar2;
+}
diff --git a/tests/diagnostics/internal-visibility/that-module.slang b/tests/diagnostics/internal-visibility/that-module.slang
new file mode 100644
index 000000000..b072c7231
--- /dev/null
+++ b/tests/diagnostics/internal-visibility/that-module.slang
@@ -0,0 +1,25 @@
+module "that-module";
+
+__include "that-module-impl";
+
+void internalMethod();
+
+public void publicMethod();
+
+public namespace Namespace
+{
+ static int internalVar;
+
+ public static int publicVar;
+}
+
+enum InternalEnum
+{
+ A,B,C
+}
+public enum PublicEnum
+{
+ D,E,F
+}
+
+struct InternalStruct { int x; }
diff --git a/tests/diagnostics/internal-visibility/this-module.slang b/tests/diagnostics/internal-visibility/this-module.slang
new file mode 100644
index 000000000..98e0f3d08
--- /dev/null
+++ b/tests/diagnostics/internal-visibility/this-module.slang
@@ -0,0 +1,26 @@
+//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):
+
+module "this-module";
+
+import "that-module";
+
+void test()
+{
+ PublicStruct s;
+ // CHECK:{{.*}}(11): error 30600:
+ s.x = 1; // Error.
+ // CHECK-NOT:{{.*}}error
+ s.y = 2; // OK.
+ publicMethod(); // OK.
+ publicFunc2(); // OK.
+ Namespace.publicVar = 1; // OK.
+ Namespace.publicVar2 = 1; // OK.
+ // CHECK:{{.*}}(19): error 30600:
+ Namespace.internalVar = 1; // error.
+ // CHECK:{{.*}}(21): error 30600:
+ InternalEnum e; // Error.
+ // CHECK:{{.*}}(23): error 30600:
+ InternalStruct s1; // Error.
+ // CHECK:{{.*}}(25): error 30600:
+ internalMethod(); // Error.
+}
diff --git a/tests/diagnostics/private-visibility.slang b/tests/diagnostics/private-visibility.slang
new file mode 100644
index 000000000..7c0bad970
--- /dev/null
+++ b/tests/diagnostics/private-visibility.slang
@@ -0,0 +1,44 @@
+//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):
+
+struct MyType
+{
+ private int member;
+ private int func()
+ {
+ return member;
+ }
+ struct SubType
+ {
+ int member2;
+ int func2(MyType m)
+ {
+ return m.member + member2; // OK.
+ }
+ }
+ int func1() { return member; }
+
+ private __init() { member = 0; }
+
+ private __subscript(int i)->int
+ {
+ get { return member; }
+ set { member = newValue; }
+ }
+ // CHECK:{{.*}}(28): error 30601:
+ public void publicMethod() {} // ERROR.
+}
+
+void test()
+{
+ // CHECK:{{.*}}(34): error 30600:
+ MyType t; // ERROR.
+ // CHECK-NOT:{{.*}}error
+ t.func1(); // OK.
+ // CHECK:{{.*}}(38): error 30600:
+ t.func(); // ERROR.
+ // CHECK:{{.*}}(40): error 30600:
+ t[0] = 1; // ERROR.
+
+ // CHECK:{{.*}}(43): error 30600:
+ t.member = 2;
+}
diff --git a/tests/diagnostics/visibility.slang b/tests/diagnostics/visibility.slang
new file mode 100644
index 000000000..724ec30e7
--- /dev/null
+++ b/tests/diagnostics/visibility.slang
@@ -0,0 +1,23 @@
+//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):
+
+// CHECK-DAG:{{.*}}(4): error 30603
+private struct MyStruct
+{}
+
+struct IS
+{
+ // CHECK-DAG:{{.*}}(10): error 30601
+ public void fp();
+}
+
+// CHECK-DAG:{{.*}}(14): error 30604
+public IS f() {}
+
+public struct PS
+{
+ // CHECK-DAG:{{.*}}(19): error 30604
+ public IS ii;
+
+ // CHECK-DAG:{{.*}}(22): error 30604
+ public property IS ii2 { get { return {}; } };
+}