summary refs log tree commit diff stats
path: root/tests/concepts/t5642.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-05-16 17:29:44 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-05-16 17:29:44 +0200
commita5695c13afabac6e67ff677d564b6d1a6aeb1af4 (patch)
tree6a5f1f1b4e808003dfd9851113e789ff2fe051d2 /tests/concepts/t5642.nim
parentc3c37dbb1574db5078b86be29804990d153ec1c1 (diff)
parent3e52bb6535a70339cf4a15123be09916ef0c31f6 (diff)
downloadNim-a5695c13afabac6e67ff677d564b6d1a6aeb1af4.tar.gz
Merge branch 'zahary' into araq
Diffstat (limited to 'tests/concepts/t5642.nim')
-rw-r--r--tests/concepts/t5642.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/concepts/t5642.nim b/tests/concepts/t5642.nim
new file mode 100644
index 000000000..d1e7bd1dd
--- /dev/null
+++ b/tests/concepts/t5642.nim
@@ -0,0 +1,25 @@
+discard """
+  output: 9
+"""
+
+type DataTable = concept x
+  x is object
+  for f in fields(x):
+    f is seq
+
+type Students = object
+   id : seq[int]
+   name : seq[string]
+   age: seq[int]
+
+proc nrow*(dt: DataTable) : Natural =
+  var totalLen = 0
+  for f in fields(dt):
+    totalLen += f.len
+  return totalLen
+
+let
+ stud = Students (id : @[1,2,3], name : @["Vas", "Pas", "NafNaf"], age : @[10,16,32])
+
+echo nrow(stud)
+