-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixes #9578 * fixed and expanded test
- Loading branch information
Showing
7 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
discard """ | ||
output: ''' | ||
@[(v: -1), (v: 2), (v: 3)] | ||
@[(v: -1), (v: 2), (v: 3)] | ||
[(v: -1), (v: 2), (v: 3)] | ||
[(v: -1), (v: 2), (v: 3)] | ||
((v: -1), (v: 2), (v: 3)) | ||
((v: -1), (v: 2), (v: 3)) | ||
@[(v: -1), (v: 2), (v: 3)] | ||
@[(v: -1), (v: 2), (v: 3)] | ||
@[(v: -1), (v: 2), (v: 3)] | ||
''' | ||
""" | ||
|
||
type mytype* = object | ||
v:int | ||
|
||
proc f*(x:ptr mytype) = x.v = -1 | ||
|
||
func g(x:int):mytype = mytype(v:x) | ||
|
||
|
||
import xseq9578 | ||
block: | ||
var x = @[1.g,2.g,3.g] | ||
testSeq(x) | ||
echo x | ||
block: | ||
var x = @[1.g,2.g,3.g] | ||
var y = addr x | ||
testSeq2(y) | ||
echo x | ||
|
||
|
||
import xarray9578 | ||
block: | ||
var x = [1.g,2.g,3.g] | ||
testArray(x) | ||
echo x | ||
block: | ||
var x = [1.g,2.g,3.g] | ||
var y = addr x | ||
testArray2(y) | ||
echo x | ||
|
||
|
||
import xtuple9578 | ||
block: | ||
var x = (1.g,2.g,3.g) | ||
testTuple(x) | ||
echo x | ||
block: | ||
var x = (1.g,2.g,3.g) | ||
var y = addr x | ||
testTuple2(y) | ||
echo x | ||
|
||
|
||
import xoa9578 | ||
block: | ||
var x = @[1.g,2.g,3.g] | ||
testOpenArray(x) | ||
echo x | ||
|
||
|
||
import xua9578 | ||
block: | ||
var x = @[1.g,2.g,3.g] | ||
var y = cast[ptr UncheckedArray[mytype]](addr x[0]) | ||
testUncheckedArray(y[]) | ||
echo x | ||
block: | ||
var x = @[1.g,2.g,3.g] | ||
var y = cast[ptr UncheckedArray[mytype]](addr x[0]) | ||
testUncheckedArray2(y) | ||
echo x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import t9578 | ||
|
||
proc testArray*(x: var array[3,mytype]) = | ||
f(x[0].addr) | ||
|
||
proc testArray2*(x: var ptr array[3,mytype]) = | ||
f(x[0].addr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import t9578 | ||
|
||
proc testOpenArray*(x: var openArray[mytype]) = | ||
f(x[0].addr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import t9578 | ||
|
||
proc testSeq*(x: var seq[mytype]) = | ||
f(x[0].addr) | ||
|
||
proc testSeq2*(x: var ptr seq[mytype]) = | ||
f(x[0].addr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import t9578 | ||
|
||
proc testTuple*(x: var tuple[a:mytype,b:mytype,c:mytype]) = | ||
f(x[0].addr) | ||
|
||
proc testTuple2*(x: var ptr tuple[a:mytype,b:mytype,c:mytype]) = | ||
f(x[0].addr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import t9578 | ||
|
||
proc testUncheckedArray*(x: var UncheckedArray[mytype]) = | ||
f(x[0].addr) | ||
|
||
proc testUncheckedArray2*(x: var ptr UncheckedArray[mytype]) = | ||
f(x[0].addr) |