added test case and updated CHANGELOG
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 30 Jun 2023 01:26:47 +0000 (20:26 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 30 Jun 2023 01:26:47 +0000 (20:26 -0500)
CHANGELOG
tests/operators_as_methods [new file with mode: 0644]
tests/operators_as_methods.onyx [new file with mode: 0644]

index 77975d02d1df706b440b249a22bf46c1423d40b8..03643ece2c6f4c4836eca88be91020861f5747ec 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,10 +8,13 @@ Additions:
 - Infrastructure to have custom sub-commands.
     - Any `*.wasm` file in `$ONYX_PATH/tools` is available to run with `onyx <cmd>`
 - `__futex_wait` and `__futex_wake` to platform layer.
-    - This allows for non-busy-waiting on mutexes on semaphores.
+    - This allows for non-busy-waiting on mutexes and semaphores.
     - Currently implemented for Onyx and JS platforms; WASI is impossible, but WASIX will come soon.
 - `--skip-native` flag to `onyx pkg sync` to skip compiling native libraries.
 - Ability to tag methods on structures.
+- `tty_get` and `tty_set` functions in `core.os`
+    - Allows for controlling raw and echoed input
+    - Currently only for `onyx` runtime and on Linux only.
 
 Removals:
 
diff --git a/tests/operators_as_methods b/tests/operators_as_methods
new file mode 100644 (file)
index 0000000..6824d74
--- /dev/null
@@ -0,0 +1,2 @@
+If works!
+Working!
diff --git a/tests/operators_as_methods.onyx b/tests/operators_as_methods.onyx
new file mode 100644 (file)
index 0000000..ff98581
--- /dev/null
@@ -0,0 +1,25 @@
+use core {*}
+use runtime
+
+#inject runtime.vars.Onyx_Enable_Operator_Methods :: true
+
+main :: () {
+    Point :: struct {
+        x, y: i32;
+
+        __eq :: (p1, p2: Point) => {
+            return p1.x == p2.x && p1.y == p2.y;
+        }
+    }
+
+    p := Point.{1, 2};
+
+    if p == Point.{1, 2} {
+        println("If works!");
+    }
+
+    switch p {
+        case .{0, 0} ---
+        case .{1, 2} do println("Working!");
+    }
+}