added object type
This commit is contained in:
parent
3bf8c47b3c
commit
f9b5f62e65
1 changed files with 19 additions and 9 deletions
28
src/root.zig
28
src/root.zig
|
|
@ -1,13 +1,23 @@
|
|||
//! By convention, root.zig is the root source file when making a library. If
|
||||
//! you are making an executable, the convention is to delete this file and
|
||||
//! start with main.zig instead.
|
||||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
|
||||
pub export fn add(a: i32, b: i32) i32 {
|
||||
return a + b;
|
||||
}
|
||||
const Raw = union(enum) {
|
||||
string: []u8,
|
||||
binary: []u8,
|
||||
};
|
||||
|
||||
test "basic add functionality" {
|
||||
try testing.expect(add(3, 7) == 10);
|
||||
const Object = union(enum) {
|
||||
nil,
|
||||
bool: bool,
|
||||
integer: i64,
|
||||
float: f64,
|
||||
raw: Raw,
|
||||
array: []Object,
|
||||
map: []struct { key: Object, value: Object },
|
||||
extension: struct { type: u8, bytes: []u8 },
|
||||
};
|
||||
|
||||
test {
|
||||
const o: Object = .nil;
|
||||
|
||||
_ = o;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue