Skip to content

Commit

Permalink
Rename to typeOf.
Browse files Browse the repository at this point in the history
  • Loading branch information
fubark committed Sep 2, 2024
1 parent 0942a29 commit cf24d0d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/builtins/builtins_vm.cy
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func sizeof[T](T type) int:
@host func sizeof_(type_id int) int

--| Returns the type of an expression.
func typeof(t ExprType) type:
func typeOf(t ExprType) type:
return t.getType()

--|
Expand Down
2 changes: 1 addition & 1 deletion test/core/lists.cy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ t.eq(a.len(), 2)

-- Explicit list type.
var ta = List[int]{1, 2, 3}
t.eq(typeof(ta), List[int])
t.eq(typeOf(ta), List[int])
t.eq(ta.len(), 3)
t.eq(ta[0], 1)

Expand Down
2 changes: 1 addition & 1 deletion test/errors/error_values.cy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use t 'test'

var err = error.FileNotFound
t.eq(typeof(err), error)
t.eq(typeOf(err), error)
t.eq(err, error.FileNotFound)

-- error.value()
Expand Down
30 changes: 15 additions & 15 deletions test/modules/core.cy
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ t.eq(newS.bar, rcList)

-- int()
dyn res = int('100')
t.eq(typeof(res), int)
t.eq(typeOf(res), int)
t.eq(res, 100)
t.eq(int(100.1), 100)
t.eq(int('100'), 100)
Expand Down Expand Up @@ -120,22 +120,22 @@ t.eq(String(error.foo), 'error.foo')
t.eq(String(symbol.foo), 'symbol.foo')
t.eq(String(float), 'type: float')

-- typeof()
t.eq(typeof(true), bool)
t.eq(typeof(false), bool)
t.eq(typeof(123), int)
t.eq(typeof(123.0), float)
t.eq(typeof(pointer(void, 123)), *void)
t.eq(typeof('abc'), String)
t.eq(typeof('abc🦊'), String)
t.eq(typeof(symbol.abc), symbol)
t.eq(typeof(error.Foo), error)
t.eq(typeof({_}), List[dyn])
t.eq(typeof(Map{}), Map)
t.eq(typeof({}), Table)
-- typeOf()
t.eq(typeOf(true), bool)
t.eq(typeOf(false), bool)
t.eq(typeOf(123), int)
t.eq(typeOf(123.0), float)
t.eq(typeOf(pointer(void, 123)), *void)
t.eq(typeOf('abc'), String)
t.eq(typeOf('abc🦊'), String)
t.eq(typeOf(symbol.abc), symbol)
t.eq(typeOf(error.Foo), error)
t.eq(typeOf({_}), List[dyn])
t.eq(typeOf(Map{}), Map)
t.eq(typeOf({}), Table)
type Foo:
a float
var foo = Foo{a=123}
t.eq(typeof(foo), Foo)
t.eq(typeOf(foo), Foo)

--cytest: pass
4 changes: 2 additions & 2 deletions test/modules/import.cy
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ t.eq(a.varMap['c'], 3)
t.eq(a.varFunc(), 345)
t.eq(a.varFunc1(10), 11)
t.eq(a.varFunc2(10, 20), 30)
t.eq(typeof(a.fn), func() int)
t.eq(typeOf(a.fn), func() int)
t.eq(a.fn(), 234)
t.eq(a.fn1(10), 11)
t.eq(a.fn2(10, 20), 30)
Expand Down Expand Up @@ -49,7 +49,7 @@ type Vec2:
-- Same name, different object types.
var v1 = Vec2{x=1, y=2}
var v2 = a.Vec2{x=3, y=4}
t.eq(typeof(v1) != typeof(v2), true)
t.eq(typeOf(v1) != typeOf(v2), true)
t.eq(v1.x, 1.0)
t.eq(v1.y, 2.0)
t.eq(v2.x, 3.0)
Expand Down
2 changes: 1 addition & 1 deletion test/vars/static_init.cy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var .a = 123
t.eq(a, 123)

-- Type is inferred from initializer.
t.eq(typeof(a), int)
t.eq(typeOf(a), int)

-- Invoke as function.
var .a1 = func() int:
Expand Down

0 comments on commit cf24d0d

Please sign in to comment.