Static instance support.
[sod] / test / bad.sod
CommitLineData
deef4956
MW
1/* -*-sod-*-
2 *
3 * A file full of terribleness, to check error reporting and recovery.
4 *
5 * (c) 2019 Straylight/Edgeware
6 */
7
8/* The reference file for this test isn't intended to be normative: it's fine
9 * if things are reordered, or messages are rephrased. But it's good to know
10 * when these things change, and besides this approach is way easier than the
11 * alternatives.
12 */
13
14typename Bad;
15
16import "chimaera";
17
18lisp ;this is actually a comment
19 (format t ";; Hello from Lisp!~%")
20 /* and this is the statement terminator */;
21
22lisp
23(define-pluggable-parser module test (scanner pset)
24 ;; `demo' string `;'
25 (declare (ignore pset))
26 (with-parser-context (token-scanner-context :scanner scanner)
27 (parse (seq ("demo" (string (must :string)) (nil (must #\;)))
28 (format t ";; DEMO ~S~%" string)))));
29demo "foo";
30
31code c: user ( not like this '' 'xyz' );
32
33class {
34}
35
36class Wrong {
37 void frob() { ... }
38 void wrong.frob() { ... }
39
40 int x = 2;
41 wrong.x = 7;
ed3ce6c2 42 int x;
deef4956 43 wrong.x = 3;
ed3ce6c2
MW
44 const char *x = "hello";
45 int x, y(), .z[45], q;
deef4956
MW
46 int wrong.fizzbuzz(int n) extern;
47 wtf.y = 19, wrong.z = 69, x.= r;
48 int (*bogon)(const char *) { return strlen(p); }
49}
50
51class Fail: SodObject { void badkw(?int x) extern; void ebw(?) extern; }
52class Unlikely: Fail { void fail.badkw(?double y) extern; }
53class Whoops: Fail { void fail.badkw(?int y) extern; }
54class Arrgh: Unlikely, Whoops {
55 void fail.badkw(?double x) extern;
56 void fail.ebw(?) extern;
57}
58
59[nick = join] class JSuper: SodObject { }
60[nick = sub] class LSub: JSuper { }
61[nick = sub] class RSub: JSuper { }
62[nick = join] class BadNicks: LSub, RSub { }
63class Super: SodObject { }
64class Left: Super { }
65class Right: Super { }
66class Join: Left, Right { }
67class Nioj: Right, Left { }
68class Splinch: Join, SodObject, Nioj { }
69[link = Super] class Hopeless: Wrong { }
70
71[link = SodClass]
72class MyClass: SodClass {
73 int foo = 1;
74 int bar = 2;
75}
76
77class MyOtherClass: SodClass { }
78
79[metaclass = MyClass, link = SodObject]
80class MyObject: SodObject {
81 class myclass.foo = 42;
82}
83
84[metaclass = MyOtherClass] class MyOtherObject: SodObject { }
85class WhichMetaClass: MyObject, MyOtherObject { }
86
87class dismissed;
88
89class hopeful: dismissed
90;
00d59354
MW
91
92[nick = st] class Static: SodObject { int x, y; }
93instance Static noinit;
94instance Static dupinit: st.x = 1, st.x = 2, st.y = 3;