Skip to content

Commit 5b29784

Browse files
committed
implement -repr for Type
1 parent 7db4d84 commit 5b29784

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

pixie/vm/stdlib.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ def _str(tp):
163163
import pixie.vm.string as string
164164
return string.rt.wrap(u"<type " + tp._name + u">")
165165

166+
@extend(_repr, Type)
167+
def _repr(tp):
168+
import pixie.vm.string as string
169+
return string.rt.wrap(tp._name)
166170

167171
@extend(_first, nil._type)
168172
def _first(_):

tests/test-stdlib.pxi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
(t/assert= (str #{1}) "#{1}")
1616
(t/assert= (str {}) "{}")
1717
(t/assert= (str {:a 1}) "{:a 1}")
18+
(t/assert= (str (type 3)) "<type pixie.stdlib.Integer>")
1819

1920
(t/assert= (str [1 {:a 1} "hey"]) "[1 {:a 1} hey]"))
2021

@@ -32,6 +33,7 @@
3233
(t/assert= (-repr #{1}) "#{1}")
3334
(t/assert= (-repr {}) "{}")
3435
(t/assert= (-repr {:a 1}) "{:a 1}")
36+
(t/assert= (-repr (type 3)) "pixie.stdlib.Integer")
3537

3638
(t/assert= (-repr [1 {:a 1} "hey"]) "[1 {:a 1} \"hey\"]"))
3739

0 commit comments

Comments
 (0)