nomen-lang 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,170 @@
1
+ #include <stdint.h>
2
+ struct Stringable;
3
+ struct Disposable;
4
+ struct Equatable;
5
+ struct Hashable;
6
+ struct Viewable;
7
+ struct Console;
8
+ struct Time;
9
+ struct Tester;
10
+ struct Math;
11
+ struct Buffer_int;
12
+ struct List_int;
13
+ // Trait Stringable
14
+ struct Stringable;
15
+ char* Stringable_to_string(struct Stringable *self);
16
+
17
+ // Trait Disposable
18
+ struct Disposable;
19
+ void Disposable_dispose(struct Disposable *self);
20
+
21
+ // Trait Equatable
22
+ struct Equatable;
23
+
24
+ // Trait Hashable
25
+ struct Hashable;
26
+ unsigned long Hashable_hash(struct Hashable *self);
27
+
28
+ // Trait Viewable
29
+ struct Viewable;
30
+
31
+ char* int_to_string(long self);
32
+ long int_parse(char* s);
33
+ char* char_to_string(char self);
34
+ char* bool_to_string(unsigned char self);
35
+ char* string_to_string(char* self);
36
+ char string_at(char* self, long index);
37
+ nomen_view string_slice(char* self, long start, long end);
38
+ void string_set(char* *self, long index, char value);
39
+ unsigned char string_eq(char* self, char* other);
40
+ char* string_add(char* self, char* other);
41
+ char* string_mul(char* self, long count);
42
+ // Struct Console
43
+ struct Console;
44
+ struct Console Console_init();
45
+ void Console_write(char* line);
46
+ void Console_write_line(char* line);
47
+ char* Console_read_line();
48
+ char Console_read_char();
49
+ char* Console_platform();
50
+
51
+ char* uint_to_string(unsigned long self);
52
+ char* int8_to_string(char self);
53
+ char* uint8_to_string(unsigned char self);
54
+ char* float_to_string(double self);
55
+ char* uint64_to_string(unsigned long long self);
56
+ // Struct Time
57
+ struct Time;
58
+ struct Time Time_init();
59
+ unsigned long long Time_now_ms();
60
+ #include <time.h>
61
+ unsigned long long Time_now_ns();
62
+ unsigned long long Time_now_unix();
63
+ void Time_sleep_ms(unsigned long long ms);
64
+
65
+ char* int64_to_string(long long self);
66
+ // Struct Tester
67
+ struct Tester;
68
+ struct Tester* Tester_init();
69
+ void Tester_begin_test(struct Tester *self, char* name);
70
+ void Tester_end_test(struct Tester *self);
71
+ unsigned char Tester_any_failed(struct Tester *self);
72
+ void Tester_expect(struct Tester *self, unsigned char condition, char* message);
73
+ void Tester_fail(struct Tester *self, char* message);
74
+ void Tester_assert_int_string(struct Tester *self, long value, char* message);
75
+ void Tester_assert_uint_string(struct Tester *self, unsigned long value, char* message);
76
+ void Tester_assert_int64_string(struct Tester *self, long long value, char* message);
77
+ void Tester_assert_uint64_string(struct Tester *self, unsigned long long value, char* message);
78
+ void Tester_assert_int8_string(struct Tester *self, char value, char* message);
79
+ void Tester_assert_uint8_string(struct Tester *self, unsigned char value, char* message);
80
+ void Tester_assert_float_string(struct Tester *self, double value, char* message);
81
+ void Tester_assert_bool_string(struct Tester *self, unsigned char value, char* message);
82
+ void Tester_assert_char_string(struct Tester *self, char value, char* message);
83
+ void Tester_assert_string_string(struct Tester *self, char* value, char* message);
84
+ void Tester_bench(struct Tester *self, char* label, void* body);
85
+ void Tester_bench_n(struct Tester *self, char* label, void* body, long samples);
86
+ void Tester_record_bench(struct Tester *self, char* label, long n, long min, long median, long max, double mean, double stddev);
87
+ void Tester_record_failure(struct Tester *self, char* message);
88
+ void Tester_destroy(struct Tester *self);
89
+
90
+ // Struct Math
91
+ struct Math;
92
+ struct Math Math_init();
93
+ long Math_power(long base, long exp);
94
+ double Math_sqrt(double x);
95
+ double Math_log(double x);
96
+
97
+ // Struct Buffer_int
98
+ struct Buffer_int;
99
+ struct Buffer_int Buffer_int_init();
100
+ long Buffer_int_alloc(struct Buffer_int *self, long size);
101
+ long Buffer_int_grow(struct Buffer_int *self, long needed);
102
+ void Buffer_int_zero(struct Buffer_int *self, long len);
103
+ unsigned int Buffer_int_load(struct Buffer_int *self, long i);
104
+ void Buffer_int_store(struct Buffer_int *self, long i, unsigned int val);
105
+ void Buffer_int_store_or(struct Buffer_int *self, long i, unsigned int val);
106
+ long Buffer_int_alloc_int(struct Buffer_int *self, long size);
107
+ long Buffer_int_grow_int(struct Buffer_int *self, long needed);
108
+ long Buffer_int_load_int(struct Buffer_int *self, long i);
109
+ void Buffer_int_store_int(struct Buffer_int *self, long i, long val);
110
+ long Buffer_int_move_int(struct Buffer_int *self, long i);
111
+ void Buffer_int_replace_int(struct Buffer_int *self, long i, long val);
112
+ void Buffer_int_zero_int(struct Buffer_int *self, long len);
113
+ long Buffer_int_alloc_T(struct Buffer_int *self, long size);
114
+ long Buffer_int_grow_T(struct Buffer_int *self, long needed);
115
+ long Buffer_int_load_T(struct Buffer_int *self, long i);
116
+ void Buffer_int_store_T(struct Buffer_int *self, long i, long val);
117
+ nomen_view Buffer_int_slice(struct Buffer_int *self, long start, long end);
118
+ void Buffer_int_zero_T(struct Buffer_int *self, long len);
119
+ void Buffer_int_store_or_int(struct Buffer_int *self, long i, long val);
120
+ long Buffer_int_alloc_float(struct Buffer_int *self, long size);
121
+ double Buffer_int_load_float(struct Buffer_int *self, long i);
122
+ void Buffer_int_store_float(struct Buffer_int *self, long i, double val);
123
+ void Buffer_int_destroy(struct Buffer_int *self);
124
+
125
+ // Struct List_int
126
+ void List_int_destroy(struct List_int *);
127
+ struct List_int;
128
+ struct List_int List_int_init();
129
+ void List_int_push(struct List_int *self, long value);
130
+ long List_int_pop(struct List_int *self);
131
+ long List_int_at(struct List_int *self, long i);
132
+ nomen_view List_int_slice(struct List_int *self, long start, long end);
133
+ void List_int_set(struct List_int *self, long i, long value);
134
+ void List_int_destroy(struct List_int *self);
135
+
136
+ // Func add
137
+ long add(long a, long b);
138
+
139
+ // Func mul
140
+ long mul(long a, long b);
141
+
142
+ // Func add_once
143
+ void add_once();
144
+
145
+ // Func test_add
146
+ void test_add(struct Tester **t);
147
+
148
+ // Func test_mul
149
+ void test_mul(struct Tester **t);
150
+
151
+ // Func test_assert_not_null
152
+ void test_assert_not_null(struct Tester **t);
153
+
154
+ // Func bench_add
155
+ void bench_add(struct Tester **t);
156
+
157
+ // Func bench_loop_bench_add
158
+ void bench_loop_bench_add(struct Tester **t);
159
+
160
+ // Func main
161
+ int main();
162
+
163
+ void **_get_trait_func(void **obj, int trait_index, int func_index);
164
+ void Stringable_destroy(void *obj);
165
+ void Disposable_destroy(void *obj);
166
+ void Equatable_destroy(void *obj);
167
+ void Hashable_destroy(void *obj);
168
+ void Viewable_destroy(void *obj);
169
+ char *_string_interpolate_3(char *pattern, char *arg1, char *arg2, char *arg3);
170
+ char *_string_interpolate_6(char *pattern, char *arg1, char *arg2, char *arg3, char *arg4, char *arg5, char *arg6);
@@ -0,0 +1,32 @@
1
+ import System
2
+ import System/Test
3
+
4
+ func add = (int a, int b, out int) => a + b
5
+ func mul = (int a, int b, out int) => a * b
6
+
7
+ // The function under test.
8
+ func add_once = () {
9
+ const int r = add(1, 1)
10
+ }
11
+
12
+ pub func test_add = (ref Tester t) {
13
+ t.expect(add(1, 1) == 2, "1 + 1 should be 2")
14
+ t.expect(add(2, 3) == 5, "2 + 3 should be 5")
15
+ t.expect(add(100, 1) == 101, "100 + 1 should be 101")
16
+ }
17
+
18
+ pub func test_mul = (ref Tester t) {
19
+ t.expect(mul(2, 2) == 4, "2 * 2 should be 4")
20
+ t.expect(mul(3, 3) == 10, "3 * 3 should be 9 (this fails on purpose)")
21
+ }
22
+
23
+ pub func test_assert_not_null = (ref Tester t) {
24
+ var int? maybe = 42
25
+ t.assert(maybe, "maybe should hold a value")
26
+ var string? none = null
27
+ t.assert(none, "none should be null (this fails on purpose)")
28
+ }
29
+
30
+ pub func bench_add = (ref Tester t) {
31
+ t.bench("add", add_once)
32
+ }