diff options
Diffstat (limited to 'testsuite')
| -rw-r--r-- | testsuite/compilable/generic_alias.elna | 10 | ||||
| -rw-r--r-- | testsuite/compilable/generic_arguments.elna | 18 | ||||
| -rw-r--r-- | testsuite/compilable/generic_base_chain.elna | 14 | ||||
| -rw-r--r-- | testsuite/compilable/generic_const_inference.elna | 4 | ||||
| -rw-r--r-- | testsuite/compilable/generic_inference.elna | 10 | ||||
| -rw-r--r-- | testsuite/compilable/generic_pointee.elna | 17 | ||||
| -rw-r--r-- | testsuite/fail_compilation/generic_arity.elna | 2 | ||||
| -rw-r--r-- | testsuite/fail_compilation/generic_base_mismatch.elna | 10 | ||||
| -rw-r--r-- | testsuite/fail_compilation/generic_by_value.elna | 7 | ||||
| -rw-r--r-- | testsuite/fail_compilation/generic_field_by_value.elna | 8 | ||||
| -rw-r--r-- | testsuite/fail_compilation/generic_parameter_arithmetic.elna | 5 | ||||
| -rw-r--r-- | testsuite/fail_compilation/generic_uninferrable.elna | 2 | ||||
| -rw-r--r-- | testsuite/runnable/generic_base.elna | 14 | ||||
| -rw-r--r-- | testsuite/runnable/generic_constructor.elna | 6 | ||||
| -rw-r--r-- | testsuite/runnable/generic_erasure.elna | 12 | ||||
| -rw-r--r-- | testsuite/runnable/generic_record.elna | 8 |
16 files changed, 89 insertions, 58 deletions
diff --git a/testsuite/compilable/generic_alias.elna b/testsuite/compilable/generic_alias.elna index 47ac638..da9501a 100644 --- a/testsuite/compilable/generic_alias.elna +++ b/testsuite/compilable/generic_alias.elna @@ -6,7 +6,7 @@ type Node#[T] = record next: ^Node#[T]; - value: T + value: ^T end Ref#[T] = ^T @@ -16,10 +16,10 @@ type end var - chain: Node#[^File] - aliased: Ref#[^File] - raw: ^^File - boxed: Boxed#[^File] + chain: Node#[File] + aliased: Ref#[File] + raw: ^File + boxed: Boxed#[File] begin chain.next := nil; diff --git a/testsuite/compilable/generic_arguments.elna b/testsuite/compilable/generic_arguments.elna index 4d33db5..1cda57f 100644 --- a/testsuite/compilable/generic_arguments.elna +++ b/testsuite/compilable/generic_arguments.elna @@ -5,22 +5,22 @@ type end Pair#[K, V] = record - key: K; - value: V + key: ^K; + value: ^V end var - entry: Pair#[^File, ^Word8] + entry: Pair#[File, Word8] -proc allocate#[T](size: Word) -> T +proc allocate#[T](size: Word) -> ^T extern -proc first#[K, V](entry_ptr: ^Pair#[K, V]) -> K +proc first#[K, V](entry_ptr: ^Pair#[K, V]) -> ^K return entry_ptr^.key begin - entry.key := allocate#[^File](#size(File)); - assert(#size(Pair#[^File, ^Word8]) = #size(Pointer) * 2u); - assert(#offset(Pair#[^File, ^Word8], value) = #size(Pointer)); - assert(first#[^File, ^Word8](@entry) = entry.key) + entry.key := allocate#[File](#size(File)); + assert(#size(Pair#[File, Word8]) = #size(Pointer) * 2u); + assert(#offset(Pair#[File, Word8], value) = #size(Pointer)); + assert(first#[File, Word8](@entry) = entry.key) end. diff --git a/testsuite/compilable/generic_base_chain.elna b/testsuite/compilable/generic_base_chain.elna index c303e6d..1abe199 100644 --- a/testsuite/compilable/generic_base_chain.elna +++ b/testsuite/compilable/generic_base_chain.elna @@ -5,20 +5,20 @@ type end Map#[K, V] = record - key: K; - value: V + key: ^K; + value: ^V end - Cache#[K, V] = record(Map#[^Word8, V]) - newest: K + Cache#[K, V] = record(Map#[Word8, V]) + newest: ^K end var - store: Cache#[^Int, ^File] + store: Cache#[Int, File] byte_key: ^Word8 - upcast: ^Map#[^Word8, ^File] + upcast: ^Map#[Word8, File] -proc put#[K2, V2](target: ^Map#[K2, V2]; key: K2) +proc put#[K2, V2](target: ^Map#[K2, V2]; key: ^K2) begin target^.key := key return diff --git a/testsuite/compilable/generic_const_inference.elna b/testsuite/compilable/generic_const_inference.elna index a9fc41f..7ce197f 100644 --- a/testsuite/compilable/generic_const_inference.elna +++ b/testsuite/compilable/generic_const_inference.elna @@ -10,10 +10,10 @@ var nested: NestedConst := nil direct_const: const ^Word8 := nil -proc write#[T](fd: Int; buf: T; count: Int) -> Int +proc write#[T](fd: Int; buf: ^T; count: Int) -> Int return 0 -proc write_const#[T](fd: Int; buf: const T; count: Int) -> Int +proc write_const#[T](fd: Int; buf: ^const T; count: Int) -> Int return 0 begin diff --git a/testsuite/compilable/generic_inference.elna b/testsuite/compilable/generic_inference.elna index 860eab1..9d7fed6 100644 --- a/testsuite/compilable/generic_inference.elna +++ b/testsuite/compilable/generic_inference.elna @@ -5,20 +5,20 @@ type end Cell#[T] = record - held: T + held: ^T end var - files: Cell#[^File] - bytes: Cell#[^Word8] + files: Cell#[File] + bytes: Cell#[Word8] f: File b: Word8 -proc store#[T](target: ^Cell#[T]; value: T) +proc store#[T](target: ^Cell#[T]; value: ^T) target^.held := value return -proc relay#[T](target: ^Cell#[T]; value: T) +proc relay#[T](target: ^Cell#[T]; value: ^T) store(target, value) return diff --git a/testsuite/compilable/generic_pointee.elna b/testsuite/compilable/generic_pointee.elna new file mode 100644 index 0000000..5ecaedf --- /dev/null +++ b/testsuite/compilable/generic_pointee.elna @@ -0,0 +1,17 @@ +program() + +type + File = record + fd: Int + end + +proc allocate#[T](size: Word) -> ^T +extern + +var + f: ^File + +begin + f := allocate#[File](#size(File)); + assert(f = nil) +end. diff --git a/testsuite/fail_compilation/generic_arity.elna b/testsuite/fail_compilation/generic_arity.elna index 645aded..3284a83 100644 --- a/testsuite/fail_compilation/generic_arity.elna +++ b/testsuite/fail_compilation/generic_arity.elna @@ -2,7 +2,7 @@ module type Stack#[T] = record - items: T + items: ^T end var diff --git a/testsuite/fail_compilation/generic_base_mismatch.elna b/testsuite/fail_compilation/generic_base_mismatch.elna index e361052..dd3bec7 100644 --- a/testsuite/fail_compilation/generic_base_mismatch.elna +++ b/testsuite/fail_compilation/generic_base_mismatch.elna @@ -8,17 +8,17 @@ type end List#[T] = record - head: T + head: ^T end Queue#[T] = record(List#[T]) - tail: T + tail: ^T end var - jobs: Queue#[^File] - wrong: ^List#[^Socket] + jobs: Queue#[File] + wrong: ^List#[Socket] begin - wrong := @jobs (* @Error Expected type '\^List#\[\^Socket\]', but got '\^Queue#\[\^File\]' *) + wrong := @jobs (* @Error Expected type '\^List#\[Socket\]', but got '\^Queue#\[File\]' *) end. diff --git a/testsuite/fail_compilation/generic_by_value.elna b/testsuite/fail_compilation/generic_by_value.elna new file mode 100644 index 0000000..778feca --- /dev/null +++ b/testsuite/fail_compilation/generic_by_value.elna @@ -0,0 +1,7 @@ +module + +proc foo#[T](x: T) (* @Error Opaque type 'T' cannot be used as a procedure parameter *) +begin +return + +end. diff --git a/testsuite/fail_compilation/generic_field_by_value.elna b/testsuite/fail_compilation/generic_field_by_value.elna new file mode 100644 index 0000000..66f9b46 --- /dev/null +++ b/testsuite/fail_compilation/generic_field_by_value.elna @@ -0,0 +1,8 @@ +module + +type + Cell#[T] = record + field: T (* @Error Opaque type 'T' cannot be used as a record field type *) + end + +end. diff --git a/testsuite/fail_compilation/generic_parameter_arithmetic.elna b/testsuite/fail_compilation/generic_parameter_arithmetic.elna index e05b1ee..9f6909d 100644 --- a/testsuite/fail_compilation/generic_parameter_arithmetic.elna +++ b/testsuite/fail_compilation/generic_parameter_arithmetic.elna @@ -1,9 +1,8 @@ module -proc walk#[T](value: T; step: ^T) +proc walk#[T](step: ^T) begin - step := step + 1; - value := value + 1 (* @Error Type parameter 'T' cannot be used in pointer arithmetic *) + step := step + 1 (* @Error Type parameter 'T' cannot be used in pointer arithmetic *) return end. diff --git a/testsuite/fail_compilation/generic_uninferrable.elna b/testsuite/fail_compilation/generic_uninferrable.elna index b3556d6..7eca7a9 100644 --- a/testsuite/fail_compilation/generic_uninferrable.elna +++ b/testsuite/fail_compilation/generic_uninferrable.elna @@ -2,7 +2,7 @@ program() var got: ^Word8 -proc allocate#[R](size: Word) -> R +proc allocate#[R](size: Word) -> ^R extern begin diff --git a/testsuite/runnable/generic_base.elna b/testsuite/runnable/generic_base.elna index 63737e0..161c59d 100644 --- a/testsuite/runnable/generic_base.elna +++ b/testsuite/runnable/generic_base.elna @@ -5,26 +5,26 @@ type end List#[T] = record - head: T; + head: ^T; count: Word end Queue#[T] = record(List#[T]) - tail: T + tail: ^T end var - jobs: Queue#[^File] - seen: ^List#[^File] + jobs: Queue#[File] + seen: ^List#[File] f: File -proc push#[T](target: ^List#[T]; value: T) +proc push#[T](target: ^List#[T]; value: ^T) begin target^.head := value; target^.count := target^.count + 1u return -proc enqueue#[T](target: ^Queue#[T]; value: T) +proc enqueue#[T](target: ^Queue#[T]; value: ^T) begin push(target, value); target^.tail := value @@ -36,5 +36,5 @@ begin assert(jobs.count = 1u); assert(jobs.head = @f); assert(jobs.tail = @f); - assert(#size(Queue#[^File]) = #size(Pointer) * 3u) + assert(#size(Queue#[File]) = #size(Pointer) * 3u) end. diff --git a/testsuite/runnable/generic_constructor.elna b/testsuite/runnable/generic_constructor.elna index d0a3f78..b21cd4a 100644 --- a/testsuite/runnable/generic_constructor.elna +++ b/testsuite/runnable/generic_constructor.elna @@ -5,16 +5,16 @@ type end Stack#[T] = record - items: T; + items: ^T; top: Word end var - s: Stack#[^File] + s: Stack#[File] f: File begin - s := Stack#[^File]{ top: 1u, items: @f }; + s := Stack#[File]{ top: 1u, items: @f }; assert(s.top = 1u); assert(s.items = @f) end. diff --git a/testsuite/runnable/generic_erasure.elna b/testsuite/runnable/generic_erasure.elna index 20862fa..db4d8c9 100644 --- a/testsuite/runnable/generic_erasure.elna +++ b/testsuite/runnable/generic_erasure.elna @@ -5,16 +5,16 @@ type end Cell#[T] = record - held: T + held: ^T end var - files: Cell#[^File] - bytes: Cell#[^Word8] + files: Cell#[File] + bytes: Cell#[Word8] f: File b: Word8 -proc store#[T](target: ^Cell#[T]; value: T) +proc store#[T](target: ^Cell#[T]; value: ^T) begin target^.held := value return @@ -22,8 +22,8 @@ return begin f.fd := 7; b := 3u8; - store#[^File](@files, @f); - store#[^Word8](@bytes, @b); + store#[File](@files, @f); + store#[Word8](@bytes, @b); assert(files.held^.fd = 7); assert(bytes.held^ = 3u8) end. diff --git a/testsuite/runnable/generic_record.elna b/testsuite/runnable/generic_record.elna index 4164c3d..1fff97d 100644 --- a/testsuite/runnable/generic_record.elna +++ b/testsuite/runnable/generic_record.elna @@ -5,15 +5,15 @@ type end Stack#[T] = record - items: T; + items: ^T; top: Word end var - s: Stack#[^File] + s: Stack#[File] f: File -proc push#[T](target: ^Stack#[T]; value: T) +proc push#[T](target: ^Stack#[T]; value: ^T) begin target^.items := value; target^.top := target^.top + 1u @@ -21,7 +21,7 @@ return begin s.top := 0u; - push#[^File](@s, @f); + push#[File](@s, @f); assert(s.top = 1u); assert(s.items = @f) end. |
