Skip to content

Commit 6fb6149

Browse files
committed
#2 - Readd class _Int | Update definition of _Int32 and _Int64 so they inherit from _Int | Update builtin tests
Readded the _Int class so that methods which take an int as an argument can be created and int64 and int32 inherit from it so that when those methods which take _Int arguments are called we can pass either int64 or int32 s.
1 parent b47eedd commit 6fb6149

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/JOSPreDefinitions/BuiltInTypes.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ export _Exception, _TypeException, _IO,
88
@defbuiltin _TypeException(Type{Exception})
99
@defbuiltin _IO(IO)
1010

11+
@defclass(_Int, [Top], [], metaclass=BuiltInClass)
12+
1113
@defbuiltin _Int8(Int8)
1214
@defbuiltin _Int16(Int16)
13-
@defbuiltin _Int32(Int32)
14-
@defbuiltin _Int64(Int64)
1515
@defbuiltin _Int128(Int128)
1616

17+
@defclass(_Int32, [_Int], [], metaclass=BuiltInClass)
18+
class_of(instance::Int32) = _Int32
19+
20+
@defclass(_Int64, [_Int], [], metaclass=BuiltInClass)
21+
class_of(instance::Int64) = _Int64
22+
1723
@defbuiltin _Bool(Bool)
1824

1925
@defbuiltin _Char(Char)

test/test_built_in_classes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ using Test
33

44
@testset "Built-In Classes" begin
55
@testset "Print object" begin
6-
result = @capture_out show(class_of(1))
7-
@test result == "<BuiltInClass _Int>"
6+
result = @capture_out show(class_of(Int64(1)))
7+
@test result == "<BuiltInClass _Int64>"
88

99
result = @capture_out show(class_of("Foo"))
1010
@test result == "<BuiltInClass _String>"

0 commit comments

Comments
 (0)