mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
added 'reset' magic proc
This commit is contained in:
10
tests/accept/compile/tcan_inherit_generic.nim
Normal file
10
tests/accept/compile/tcan_inherit_generic.nim
Normal file
@@ -0,0 +1,10 @@
|
||||
##
|
||||
## can_inherit_generic Nimrod Module
|
||||
##
|
||||
## Created by Eric Doughty-Papassideris on 2011-02-16.
|
||||
## Copyright (c) 2011 FWA. All rights reserved.
|
||||
|
||||
type
|
||||
TGen[T] = object
|
||||
TSpef[T] = object of TGen[T]
|
||||
|
||||
11
tests/accept/compile/tcan_specialise_generic.nim
Normal file
11
tests/accept/compile/tcan_specialise_generic.nim
Normal file
@@ -0,0 +1,11 @@
|
||||
##
|
||||
## can_specialise_generic Nimrod Module
|
||||
##
|
||||
## Created by Eric Doughty-Papassideris on 2011-02-16.
|
||||
## Copyright (c) 2011 FWA. All rights reserved.
|
||||
|
||||
type
|
||||
TGen[T] = object
|
||||
TSpef = object of TGen[string]
|
||||
|
||||
|
||||
15
tests/accept/compile/tspecialised_is_equivalent.nim
Normal file
15
tests/accept/compile/tspecialised_is_equivalent.nim
Normal file
@@ -0,0 +1,15 @@
|
||||
##
|
||||
## specialised_is_equivalent Nimrod Module
|
||||
##
|
||||
## Created by Eric Doughty-Papassideris on 2011-02-16.
|
||||
## Copyright (c) 2011 FWA. All rights reserved.
|
||||
|
||||
type
|
||||
TGen[T] = tuple[a: T]
|
||||
TSpef = tuple[a: string]
|
||||
|
||||
var
|
||||
a: TGen[string]
|
||||
b: TSpef
|
||||
a = b
|
||||
|
||||
19
tests/accept/run/tmacro4.nim
Normal file
19
tests/accept/run/tmacro4.nim
Normal file
@@ -0,0 +1,19 @@
|
||||
discard """
|
||||
output: "after"
|
||||
"""
|
||||
|
||||
import
|
||||
macros, strutils
|
||||
|
||||
macro test_macro*(n: stmt): stmt =
|
||||
result = newNimNode(nnkStmtList)
|
||||
var ass : PNimrodNode = newNimNode(nnkAsgn)
|
||||
add(ass, newIdentNode("str"))
|
||||
add(ass, newStrLitNode("after"))
|
||||
add(result, ass)
|
||||
when isMainModule:
|
||||
var str: string = "before"
|
||||
test_macro(str):
|
||||
var i : integer = 123
|
||||
echo str
|
||||
|
||||
Reference in New Issue
Block a user