test/bad.sod: Test error reporting and recovery.
[sod] / test / bad.sod
diff --git a/test/bad.sod b/test/bad.sod
new file mode 100644 (file)
index 0000000..4ca273e
--- /dev/null
@@ -0,0 +1,88 @@
+/* -*-sod-*-
+ *
+ * A file full of terribleness, to check error reporting and recovery.
+ *
+ * (c) 2019 Straylight/Edgeware
+ */
+
+/* The reference file for this test isn't intended to be normative: it's fine
+ * if things are reordered, or messages are rephrased.  But it's good to know
+ * when these things change, and besides this approach is way easier than the
+ * alternatives.
+ */
+
+typename Bad;
+
+import "chimaera";
+
+lisp ;this is actually a comment
+  (format t ";; Hello from Lisp!~%")
+  /* and this is the statement terminator */;
+
+lisp
+(define-pluggable-parser module test (scanner pset)
+  ;; `demo' string `;'
+  (declare (ignore pset))
+  (with-parser-context (token-scanner-context :scanner scanner)
+    (parse (seq ("demo" (string (must :string)) (nil (must #\;)))
+            (format t ";; DEMO ~S~%" string)))));
+demo "foo";
+
+code c: user ( not like this '' 'xyz' );
+
+class {
+}
+
+class Wrong {
+  void frob() { ... }
+  void wrong.frob() { ... }
+
+  int x = 2;
+  wrong.x = 7;
+  wrong.x = 3;
+  int filler, y(), .z[45], q;
+  int wrong.fizzbuzz(int n) extern;
+  wtf.y = 19, wrong.z = 69, x.= r;
+  int (*bogon)(const char *) { return strlen(p); }
+}
+
+class Fail: SodObject { void badkw(?int x) extern; void ebw(?) extern; }
+class Unlikely: Fail { void fail.badkw(?double y) extern; }
+class Whoops: Fail { void fail.badkw(?int y) extern; }
+class Arrgh: Unlikely, Whoops {
+  void fail.badkw(?double x) extern;
+  void fail.ebw(?) extern;
+}
+
+[nick = join] class JSuper: SodObject { }
+[nick = sub] class LSub: JSuper { }
+[nick = sub] class RSub: JSuper { }
+[nick = join] class BadNicks: LSub, RSub { }
+class Super: SodObject { }
+class Left: Super { }
+class Right: Super { }
+class Join: Left, Right { }
+class Nioj: Right, Left { }
+class Splinch: Join, SodObject, Nioj { }
+[link = Super] class Hopeless: Wrong { }
+
+[link = SodClass]
+class MyClass: SodClass {
+  int foo = 1;
+  int bar = 2;
+}
+
+class MyOtherClass: SodClass { }
+
+[metaclass = MyClass, link = SodObject]
+class MyObject: SodObject {
+  class myclass.foo = 42;
+}
+
+[metaclass = MyOtherClass] class MyOtherObject: SodObject { }
+class WhichMetaClass: MyObject, MyOtherObject { }
+
+class dismissed;
+
+class hopeful: dismissed
+;