File: tsystemcmp.nim

package info (click to toggle)
nim 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,911,644 kB
  • sloc: sh: 24,603; ansic: 1,761; python: 1,492; makefile: 1,013; sql: 298; asm: 141; xml: 13
file content (24 lines) | stat: -rw-r--r-- 471 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
discard """
  cmd: r"nim c --hints:on $options --threads:on $file"
  output: '''@["", "a", "ha", "hi", "ho", "huu"]'''
"""

import algorithm

# bug #1657
var modules = @["hi", "ho", "", "a", "ha", "huu"]
sort(modules, system.cmp)
echo modules

type
  MyType = object
    x: string

proc cmp(a, b: MyType): int = cmp(a.x, b.x)

var modulesB = @[MyType(x: "ho"), MyType(x: "ha")]
sort(modulesB, cmp)

# bug #2397

proc f(x: (proc(a,b: string): int) = system.cmp) = discard