1. KS Sreeram
  2. clay

Commits

KS Sreeram  committed f93991b

test/operators/extendedassignment: added trivial test case.

  • Participants
  • Parent commits 8a70674
  • Branches default

Comments (0)

Files changed (2)

File test/operators/extendedassignment/main.clay

View file
  • Ignore whitespace
+
+record Foo ();
+
+var dummy = 10;
+
+overload index(x:Foo, index) = ref dummy;
+overload staticIndex(x:Foo, index) = ref dummy;
+overload fieldRef(x:Foo, field) = ref dummy;
+
+overload indexAssign(x:Foo, index, value) {
+    println("indexAssign(x, ", index, ", ", value, ")");
+}
+
+overload indexUpdateAssign(op, x:Foo, index, value) {
+    println("indexUpdateAssign(", op, ", x, ", index, ", ", value, ")");
+}
+
+[i]
+overload staticIndexAssign(x:Foo, static i, value) {
+    println("staticIndexAssign(x, ", i, ", ", value, ")");
+}
+
+[i]
+overload staticIndexUpdateAssign(op, x:Foo, static i, value) {
+    println("staticIndexUpdateAssign(", op, ", x, ", i, ", ", value, ")");
+}
+
+[FIELD]
+overload fieldRefAssign(x:Foo, static FIELD, value) {
+    println("fieldRefAssign(x, ", FIELD, ", ", value, ")");
+}
+
+[FIELD]
+overload fieldRefUpdateAssign(op, x:Foo, static FIELD, value) {
+    println("fieldRefUpdateAssign(", op, ", x, ", FIELD, ", ", value, ")");
+}
+
+main() {
+    var foo = Foo();
+    foo[10] = "hello";
+    foo.20 = "hi";
+    foo.bar = "hola";
+    foo[30] += 100;
+    foo.40 *= 200;
+    foo.baz /= 300;
+}

File test/operators/extendedassignment/out.txt

View file
  • Ignore whitespace
+indexAssign(x, 10, hello)
+staticIndexAssign(x, 20, hi)
+fieldRefAssign(x, #bar, hola)
+indexUpdateAssign(add, x, 30, 100)
+staticIndexUpdateAssign(multiply, x, 40, 200)
+fieldRefUpdateAssign(divide, x, #baz, 300)