remove old implementation of the roof operator; make tests green again; close #6292
This commit is contained in:
parent
d52a1061b3
commit
f1dab39086
13 changed files with 28 additions and 161 deletions
|
|
@ -1,7 +1,6 @@
|
|||
discard """
|
||||
output: '''@[2, 3, 4]321
|
||||
9.0 4.0
|
||||
(a: 1.0, b: 2.0, c: 8.0)2.0'''
|
||||
9.0 4.0'''
|
||||
"""
|
||||
|
||||
proc foo[T](x, y: T): T = x
|
||||
|
|
@ -10,27 +9,3 @@ var a = @[1, 2, 3, 4]
|
|||
var b: array[3, array[2, float]] = [[1.0,2], [3.0,4], [8.0,9]]
|
||||
echo a[1.. ^1], a[^2], a[^3], a[^4]
|
||||
echo b[^1][^1], " ", (b[^2]).foo(b[^1])[^1]
|
||||
|
||||
type
|
||||
MyArray = object
|
||||
a, b, c: float
|
||||
|
||||
var
|
||||
ma = MyArray(a: 1.0, b: 2.0, c: 3.0)
|
||||
|
||||
proc len(x: MyArray): int = 3
|
||||
|
||||
proc `[]=`(x: var MyArray; idx: range[0..2]; val: float) =
|
||||
case idx
|
||||
of 0: x.a = val
|
||||
of 1: x.b = val
|
||||
of 2: x.c = val
|
||||
|
||||
proc `[]`(x: var MyArray; idx: range[0..2]): float =
|
||||
case idx
|
||||
of 0: result = x.a
|
||||
of 1: result = x.b
|
||||
of 2: result = x.c
|
||||
|
||||
ma[^1] = 8.0
|
||||
echo ma, ma[^2]
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
discard """
|
||||
errormsg: "invalid context for '^' as 'foo()' has side effects"
|
||||
line: "9"
|
||||
"""
|
||||
# XXX This needs to be fixed properly!
|
||||
proc foo(): seq[int] {.sideEffect.} =
|
||||
echo "ha"
|
||||
|
||||
let f = foo()[^1]
|
||||
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
discard """
|
||||
errormsg: "invalid context for '^' as len!=high+1 for 'a'"
|
||||
line: "8"
|
||||
output: '''c'''
|
||||
"""
|
||||
|
||||
var a: array[1..3, string]
|
||||
var a: array['a'..'c', string] = ["a", "b", "c"]
|
||||
|
||||
echo a[^1]
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
discard """
|
||||
errormsg: "no surrounding array access context for '^'"
|
||||
line: "37"
|
||||
"""
|
||||
|
||||
proc foo[T](x, y: T): T = x
|
||||
|
||||
var a = @[1, 2, 3, 4]
|
||||
var b: array[3, array[2, float]] = [[1.0,2], [3.0,4], [8.0,9]]
|
||||
echo a[1.. ^1], a[^2], a[^3], a[^4]
|
||||
echo b[^1][^1], " ", (b[^2]).foo(b[^1])[^1]
|
||||
|
||||
type
|
||||
MyArray = object
|
||||
a, b, c: float
|
||||
|
||||
var
|
||||
ma = MyArray(a: 1.0, b: 2.0, c: 3.0)
|
||||
|
||||
proc len(x: MyArray): int = 3
|
||||
|
||||
proc `[]=`(x: var MyArray; idx: range[0..2]; val: float) =
|
||||
case idx
|
||||
of 0: x.a = val
|
||||
of 1: x.b = val
|
||||
of 2: x.c = val
|
||||
|
||||
proc `[]`(x: var MyArray; idx: range[0..2]): float =
|
||||
case idx
|
||||
of 0: result = x.a
|
||||
of 1: result = x.b
|
||||
of 2: result = x.c
|
||||
|
||||
ma[^1] = 8.0
|
||||
echo ma, ma[^2]
|
||||
|
||||
echo(^1)
|
||||
|
|
@ -32,7 +32,7 @@ suite "captures":
|
|||
test "named capture bounds":
|
||||
let ex1 = "foo".find(re("(?<foo>foo)(?<bar>bar)?"))
|
||||
check(ex1.captureBounds["foo"] == some(0..2))
|
||||
check(ex1.captureBounds["bar"] == none(Slice[int]))
|
||||
check(ex1.captureBounds["bar"] == none(Slice[int, int]))
|
||||
|
||||
test "capture count":
|
||||
let ex1 = re("(?<foo>foo)(?<bar>bar)?")
|
||||
|
|
@ -42,7 +42,7 @@ suite "captures":
|
|||
test "named capture table":
|
||||
let ex1 = "foo".find(re("(?<foo>foo)(?<bar>bar)?"))
|
||||
check(ex1.captures.toTable == {"foo" : "foo", "bar" : nil}.toTable())
|
||||
check(ex1.captureBounds.toTable == {"foo" : some(0..2), "bar" : none(Slice[int])}.toTable())
|
||||
check(ex1.captureBounds.toTable == {"foo" : some(0..2), "bar" : none(Slice[int, int])}.toTable())
|
||||
check(ex1.captures.toTable("") == {"foo" : "foo", "bar" : ""}.toTable())
|
||||
|
||||
let ex2 = "foobar".find(re("(?<foo>foo)(?<bar>bar)?"))
|
||||
|
|
@ -51,7 +51,7 @@ suite "captures":
|
|||
test "capture sequence":
|
||||
let ex1 = "foo".find(re("(?<foo>foo)(?<bar>bar)?"))
|
||||
check(ex1.captures.toSeq == @["foo", nil])
|
||||
check(ex1.captureBounds.toSeq == @[some(0..2), none(Slice[int])])
|
||||
check(ex1.captureBounds.toSeq == @[some(0..2), none(Slice[int, int])])
|
||||
check(ex1.captures.toSeq("") == @["foo", ""])
|
||||
|
||||
let ex2 = "foobar".find(re("(?<foo>foo)(?<bar>bar)?"))
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ suite "find":
|
|||
|
||||
test "find bounds":
|
||||
check(toSeq(findIter("1 2 3 4 5 ", re" ")).map(
|
||||
proc (a: RegexMatch): Slice[int] = a.matchBounds
|
||||
proc (a: RegexMatch): Slice[int, int] = a.matchBounds
|
||||
) == @[1..1, 3..3, 5..5, 7..7, 9..9])
|
||||
|
||||
test "overlapping find":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue