Skip to content

Commit

Permalink
✅ Add tests about distinct, namedtuple
Browse files Browse the repository at this point in the history
  • Loading branch information
glassesneo committed Mar 5, 2024
1 parent b05a990 commit 76d09cf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/distinct_type.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
discard """
action: "compile"
"""

import
../src/oolib

class Dollar(distinct int):
proc `+`(other: Dollar): Dollar {.borrow, used.}
proc `-`(other: Dollar): Dollar {.borrow, used.}

var myMoney {.used.} = 12.Dollar
16 changes: 16 additions & 0 deletions tests/named_tuple.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
discard """
action: "compile"
"""

import
../src/oolib

class Person(tuple):
var name: string
var age: Natural
proc greet =
echo "Hello, I'm " & self.name & "."

let luigi: Person = ("Luigi", 26)

luigi.greet()

0 comments on commit 76d09cf

Please sign in to comment.