diff options
author | Araq <rumpf_a@web.de> | 2015-10-13 00:22:27 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-10-13 00:22:27 +0200 |
commit | d8b0edc3230b6bc1902522b40c12862487fafc82 (patch) | |
tree | d7e34249abdfc7a33ae2ae20b6e71081fbf1c77e /tests | |
parent | 2c33ebed7be1313fc66a80437a66e9d4155308a9 (diff) | |
parent | 4a471d82310659bcb9683b9e81ba9e4af5e23062 (diff) | |
download | Nim-d8b0edc3230b6bc1902522b40c12862487fafc82.tar.gz |
Merge branch 'mget' of https://github.com/def-/Nim into def--mget
Conflicts: lib/pure/collections/critbits.nim lib/pure/collections/tables.nim lib/pure/xmltree.nim lib/system/sets.nim tests/collections/ttables.nim tests/collections/ttablesref.nim
Diffstat (limited to 'tests')
-rw-r--r-- | tests/actiontable/tactiontable.nim | 1 | ||||
-rw-r--r-- | tests/collections/ttables.nim | 6 | ||||
-rw-r--r-- | tests/collections/ttablesref.nim | 6 | ||||
-rw-r--r-- | tests/misc/teventemitter.nim | 3 | ||||
-rw-r--r-- | tests/stdlib/tmget.nim | 141 | ||||
-rw-r--r-- | tests/stdlib/tmitems.nim | 2 |
6 files changed, 152 insertions, 7 deletions
diff --git a/tests/actiontable/tactiontable.nim b/tests/actiontable/tactiontable.nim index 18b0fd388..4560d0f7f 100644 --- a/tests/actiontable/tactiontable.nim +++ b/tests/actiontable/tactiontable.nim @@ -24,4 +24,3 @@ var "D": action4}.toTable actionTable["C"]("arg") - diff --git a/tests/collections/ttables.nim b/tests/collections/ttables.nim index a10606843..a8a182a78 100644 --- a/tests/collections/ttables.nim +++ b/tests/collections/ttables.nim @@ -60,8 +60,12 @@ block tableTest2: t["123"] = 1.5 # test overwriting assert t["123"] == 1.5 - assert t["111"] == 0.0 # deleted + try: + echo t["111"] # deleted + except KeyError: + discard assert(not hasKey(t, "111")) + assert "123" in t assert("111" notin t) diff --git a/tests/collections/ttablesref.nim b/tests/collections/ttablesref.nim index 0b641ebc7..32494f1f2 100644 --- a/tests/collections/ttablesref.nim +++ b/tests/collections/ttablesref.nim @@ -60,8 +60,10 @@ block tableTest2: t["123"] = 1.5 # test overwriting assert t["123"] == 1.5 - assert t["111"] == 0.0 # deleted - assert "123" in t + try: + echo t["111"] # deleted + except KeyError: + discard assert(not hasKey(t, "111")) assert "111" notin t diff --git a/tests/misc/teventemitter.nim b/tests/misc/teventemitter.nim index 32cc81be4..7da1a2522 100644 --- a/tests/misc/teventemitter.nim +++ b/tests/misc/teventemitter.nim @@ -18,7 +18,7 @@ proc on*(emitter: var EventEmitter, event: string, if not hasKey(emitter.events, event): var list: DoublyLinkedList[proc(e: EventArgs) {.nimcall.}] add(emitter.events, event, list) #if not, add it. - append(emitter.events.mget(event), fn) + append(emitter.events[event], fn) proc initEmitter(emitter: var EventEmitter) = emitter.events = initTable[string, @@ -30,4 +30,3 @@ var initEmitter(ee) ee.on("print", proc(e: EventArgs) = echo("pie")) ee.emit("print", args) - diff --git a/tests/stdlib/tmget.nim b/tests/stdlib/tmget.nim new file mode 100644 index 000000000..5792b6282 --- /dev/null +++ b/tests/stdlib/tmget.nim @@ -0,0 +1,141 @@ +discard """ + output: '''Can't access 6 +10 +11 +Can't access 6 +10 +11 +Can't access 6 +10 +11 +Can't access 6 +10 +11 +Can't access 6 +10 +11 +Can't access 6 +10 +11 +Can't access 6 +5 +Can't access 6 +10 +11 +Can't access 6 +10 +11''' +""" + +import tables + +block: + var x = initTable[int, int]() + x[5] = 10 + try: + echo x[6] + except KeyError: + echo "Can't access 6" + echo x[5] + x[5] += 1 + var c = x[5] + echo c + +block: + var x = newTable[int, int]() + x[5] = 10 + try: + echo x[6] + except KeyError: + echo "Can't access 6" + echo x[5] + x[5] += 1 + var c = x[5] + echo c + +block: + var x = initOrderedTable[int, int]() + x[5] = 10 + try: + echo x[6] + except KeyError: + echo "Can't access 6" + echo x[5] + x[5] += 1 + var c = x[5] + echo c + +block: + var x = newOrderedTable[int, int]() + x[5] = 10 + try: + echo x[6] + except KeyError: + echo "Can't access 6" + echo x[5] + x[5] += 1 + var c = x[5] + echo c + +block: + var x = initCountTable[int]() + x[5] = 10 + try: + echo x[6] + except KeyError: + echo "Can't access 6" + echo x[5] + x[5] += 1 + var c = x[5] + echo c + +block: + var x = newCountTable[int]() + x[5] = 10 + try: + echo x[6] + except KeyError: + echo "Can't access 6" + echo x[5] + x[5] += 1 + var c = x[5] + echo c + +import sets + +block: + var x = initSet[int]() + x.incl 5 + try: + echo x[6] + except KeyError: + echo "Can't access 6" + echo x[5] + +import critbits + +block: + var x: CritBitTree[int] + x["5"] = 10 + try: + echo x["6"] + except KeyError: + echo "Can't access 6" + echo x["5"] + x["5"] += 1 + var c = x["5"] + echo c + +import strtabs + +block: + var x = newStringTable() + x["5"] = "10" + try: + echo x["6"] + except KeyError: + echo "Can't access 6" + echo x["5"] + x["5"][1] = '1' + var c = x["5"] + echo c diff --git a/tests/stdlib/tmitems.nim b/tests/stdlib/tmitems.nim index 544ad0334..27ff344e5 100644 --- a/tests/stdlib/tmitems.nim +++ b/tests/stdlib/tmitems.nim @@ -132,5 +132,5 @@ block: </Students>""") for x in d.mitems: x = <>Student(Name=x.attrs["Name"] & "foo") - d.mget(1).attrs["Name"] = "bar" + d[1].attrs["Name"] = "bar" echo d |