summary refs log tree commit diff stats
path: root/tests/vm/tconsttable.nim
blob: 152a33cba63ebafbb3578518ac3c9d5e34f1ead5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
discard """
  output: '''is
finally
nice!'''
"""

import tables

const
  foo = {"ah": "finally", "this": "is", "possible.": "nice!"}.toTable()

# protect against overly smart compiler:
var x = "this"

echo foo[x]
x = "ah"
echo foo[x]
x = "possible."
echo foo[x]

block: # bug #19840
  const testBytes = [byte 0xD8, 0x08, 0xDF, 0x45, 0x00, 0x3D, 0x00, 0x52, 0x00, 0x61]
  var tempStr = "__________________"

  tempStr.prepareMutation
  copyMem(addr tempStr[0], addr testBytes[0], testBytes.len)

block: # bug #22389
  func foo(): ptr UncheckedArray[byte] =
    const bar = [77.byte]
    cast[ptr UncheckedArray[byte]](addr bar[0])

  doAssert foo()[0] == 77