summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-04-20 11:44:54 +0200
committerAraq <rumpf_a@web.de>2015-04-20 11:44:54 +0200
commit2b4e233510ed45c924507110e19cc94f1d849125 (patch)
tree6450b1b32d9df8db97bbfb298d6eccfa93656264 /tests
parent7be092bba59ceadeccff1fd884cfde0d4df92a44 (diff)
parentb4e938ca21ba5ddadb749da21f9d55db99dc9d9c (diff)
downloadNim-2b4e233510ed45c924507110e19cc94f1d849125.tar.gz
Merge branch 'devel' of https://github.com/Araq/Nim into devel
Diffstat (limited to 'tests')
-rw-r--r--tests/cpp/get_subsystem.nim22
-rw-r--r--tests/cpp/vector_iterator.nim19
-rw-r--r--tests/parser/tstrongspaces.nim14
3 files changed, 55 insertions, 0 deletions
diff --git a/tests/cpp/get_subsystem.nim b/tests/cpp/get_subsystem.nim
new file mode 100644
index 000000000..38593b03a
--- /dev/null
+++ b/tests/cpp/get_subsystem.nim
@@ -0,0 +1,22 @@
+discard """
+  cmd: "nim cpp $file"
+"""
+
+{.emit: """
+
+namespace System {
+  struct Input {};
+}
+
+struct SystemManager {
+  template <class T>
+  static T* getSubsystem() { return new T; }
+};
+
+""".}
+
+type Input {.importcpp: "System::Input".} = object
+proc getSubsystem*[T](): ptr T {.importcpp: "SystemManager::getSubsystem<'*0>()".}
+
+let input: ptr Input = getSubsystem[Input]()
+
diff --git a/tests/cpp/vector_iterator.nim b/tests/cpp/vector_iterator.nim
new file mode 100644
index 000000000..cb5ab33af
--- /dev/null
+++ b/tests/cpp/vector_iterator.nim
@@ -0,0 +1,19 @@
+discard """
+  cmd: "nim cpp $file"
+"""
+
+{.emit: """
+
+template <class T>
+struct Vector {
+  struct Iterator {};
+};
+
+""".}
+
+type
+  Vector {.importcpp: "Vector".} [T] = object
+  VectorIterator {.importcpp: "Vector<'0>::Iterator".} [T] = object
+
+var x: VectorIterator[void]
+
diff --git a/tests/parser/tstrongspaces.nim b/tests/parser/tstrongspaces.nim
index 568abda4c..e70b91988 100644
--- a/tests/parser/tstrongspaces.nim
+++ b/tests/parser/tstrongspaces.nim
@@ -15,6 +15,10 @@ true
 tester args
 all
 all args
+19
+-3
+false
+-2
 '''
 """
 
@@ -67,3 +71,13 @@ const
 echo tester & " " & args|"all"
 echo "all"  |  tester & " " & args
 echo "all"|tester & " " & args
+
+# Test arrow like operators. See also tests/macros/tclosuremacro.nim
+proc `+->`(a, b: int): int = a + b*4
+template `===>`(a, b: int): expr = a - b shr 1
+
+echo 3 +-> 2 + 2 and 4
+var arrowed = 3+->2 + 2 and 4  # arrowed = 4
+echo arrowed ===> 15
+echo (2 * 3+->2) == (2*3 +-> 2)
+echo arrowed ===> 2 + 3+->2