Skip to content

Commit 67a6ec4

Browse files
committed
Update tests
1 parent 587573c commit 67a6ec4

File tree

5 files changed

+64
-60
lines changed

5 files changed

+64
-60
lines changed

ir/IR.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ std::string IR::generate() {
6464
s << "}\n\n";
6565
}
6666

67-
if (!enums.empty()) {
68-
llvm::outs() << "import " + libObjName + "._\n\n";
67+
if (!enums.empty() || hasHelperMethods()) {
68+
s << "import " << libObjName << "._\n\n";
69+
}
6970

71+
if (!enums.empty()) {
7072
s << "object " << libName << "Enums {\n";
7173

7274
for (const auto &e : enums) {

tests/samples/Function.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import scala.scalanative.native.Nat._
55
@native.link("Function")
66
@native.extern
77
object Function {
8-
def no_args(): native.CInt = native.extern
9-
def void_arg(): native.CInt = native.extern
10-
def one_arg(a: native.CInt): Unit = native.extern
11-
def two_args(a: native.CFloat, b: native.CInt): native.Ptr[Byte] = native.extern
12-
def anonymous_args(anonymous0: native.CFloat, anonymous1: native.CInt): Unit = native.extern
13-
def variadic_args(a: native.CDouble, b: native.Ptr[Byte], varArgs: native.CVararg*): native.CDouble = native.extern
8+
def no_args(): native.CInt = native.extern
9+
def void_arg(): native.CInt = native.extern
10+
def one_arg(a: native.CInt): Unit = native.extern
11+
def two_args(a: native.CFloat, b: native.CInt): native.Ptr[Byte] = native.extern
12+
def anonymous_args(anonymous0: native.CFloat, anonymous1: native.CInt): Unit = native.extern
13+
def variadic_args(a: native.CDouble, b: native.Ptr[Byte], varArgs: native.CVararg*): native.CDouble = native.extern
1414
}

tests/samples/NativeTypes.scala

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@ import scala.scalanative.native.Nat._
55
@native.link("NativeTypes")
66
@native.extern
77
object NativeTypes {
8-
type size_t = native.CUnsignedInt
9-
type ptrdiff_t = native.CUnsignedInt
10-
type char16_t = native.CUnsignedShort
11-
type char32_t = native.CUnsignedInt
12-
type void_type = Unit
13-
type char_type = native.CChar
14-
type signed_char_type = native.CSignedChar
15-
type unsigned_char_type = native.CUnsignedChar
16-
type short_type = native.CShort
17-
type unsigned_short_type = native.CUnsignedShort
18-
type int_type = native.CInt
19-
type unsigned_int_type = native.CUnsignedInt
20-
type long_type = native.CLong
21-
type long_int_type = native.CLong
22-
type unsigned_long_type = native.CUnsignedLong
23-
type unsigned_long_int_type = native.CUnsignedLong
24-
type long_long_type = native.CLongLong
25-
type unsigned_long_long_type = native.CUnsignedLongLong
26-
type float_type = native.CFloat
27-
type double_type = native.CDouble
28-
type ptr_byte_type = native.Ptr[Byte]
29-
type ptr_int_type = native.Ptr[native.CInt]
30-
type cstring_type = native.CString
31-
type size_t_type = native.CSize
32-
type ptrdiff_t_type = native.CPtrDiff
33-
type char16_t_type = native.CChar16
34-
type char32_t_type = native.CChar32
8+
type size_t = native.CUnsignedInt
9+
type ptrdiff_t = native.CUnsignedInt
10+
type char16_t = native.CUnsignedShort
11+
type char32_t = native.CUnsignedInt
12+
type void_type = Unit
13+
type char_type = native.CChar
14+
type signed_char_type = native.CSignedChar
15+
type unsigned_char_type = native.CUnsignedChar
16+
type short_type = native.CShort
17+
type unsigned_short_type = native.CUnsignedShort
18+
type int_type = native.CInt
19+
type unsigned_int_type = native.CUnsignedInt
20+
type long_type = native.CLong
21+
type long_int_type = native.CLong
22+
type unsigned_long_type = native.CUnsignedLong
23+
type unsigned_long_int_type = native.CUnsignedLong
24+
type long_long_type = native.CLongLong
25+
type unsigned_long_long_type = native.CUnsignedLongLong
26+
type float_type = native.CFloat
27+
type double_type = native.CDouble
28+
type ptr_byte_type = native.Ptr[Byte]
29+
type ptr_int_type = native.Ptr[native.CInt]
30+
type cstring_type = native.CString
31+
type size_t_type = native.CSize
32+
type ptrdiff_t_type = native.CPtrDiff
33+
type char16_t_type = native.CChar16
34+
type char32_t_type = native.CChar32
3535
}

tests/samples/Struct.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ import scala.scalanative.native.Nat._
55
@native.link("Struct")
66
@native.extern
77
object Struct {
8-
type struct_point = native.CStruct2[native.CInt, native.CInt]
9-
type point_s = native.Ptr[struct_point]
8+
type point_s = native.Ptr[struct_point]
9+
type struct_point = native.CStruct2[native.CInt, native.CInt]
1010
}
1111

1212
import Struct._
1313

1414
object StructHelpers {
15-
implicit class struct_point_ops(val p: native.Ptr[struct_point]) extends AnyVal {
16-
def x: native.CInt = !p._1
17-
def x_=(value: native.CInt):Unit = !p._1 = value
18-
def y: native.CInt = !p._2
19-
def y_=(value: native.CInt):Unit = !p._2 = value
20-
}
2115

22-
def struct_point()(implicit z: native.Zone): native.Ptr[struct_point] = native.alloc[struct_point]
16+
implicit class struct_point_ops(val p: native.Ptr[struct_point]) extends AnyVal {
17+
def x: native.CInt = !p._1
18+
def x_=(value: native.CInt):Unit = !p._1 = value
19+
def y: native.CInt = !p._2
20+
def y_=(value: native.CInt):Unit = !p._2 = value
21+
}
2322

24-
}
23+
def struct_point()(implicit z: native.Zone): native.Ptr[struct_point] = native.alloc[struct_point]
24+
}

tests/samples/Typedef.scala

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,26 @@ import scala.scalanative.native.Nat._
55
@native.link("Typedef")
66
@native.extern
77
object Typedef {
8-
type enum_days = native.CInt
9-
type enum_toggle_e = native.CInt
10-
type toggle_e = enum_toggle_e
11-
type int2int = native.CFunctionPtr1[native.CInt, native.CInt]
12-
type day2string = native.CFunctionPtr1[enum_days, native.CString]
13-
type toggle = native.CFunctionPtr1[toggle_e, Unit]
8+
type toggle_e = enum_toggle_e
9+
type int2int = native.CFunctionPtr1[native.CInt, native.CInt]
10+
type day2string = native.CFunctionPtr1[enum_days, native.CString]
11+
type toggle = native.CFunctionPtr1[toggle_e, Unit]
12+
type enum_days = native.CInt
13+
type enum_toggle_e = native.CInt
1414
}
1515

1616
import Typedef._
1717

1818
object TypedefEnums {
19-
final val enum_days_MONDAY = 0
20-
final val enum_days_TUESDAY = 1
21-
final val enum_days_WEDNESDAY = 2
22-
final val enum_days_THURSDAY = 3
23-
final val enum_days_FRIDAY = 4
24-
final val enum_days_SATURDAY = 5
25-
final val enum_days_SUNDAY = 6
26-
final val enum_toggle_e_OFF = 0
27-
final val enum_toggle_e_ON = 1
19+
final val enum_days_MONDAY = 0
20+
final val enum_days_TUESDAY = 1
21+
final val enum_days_WEDNESDAY = 2
22+
final val enum_days_THURSDAY = 3
23+
final val enum_days_FRIDAY = 4
24+
final val enum_days_SATURDAY = 5
25+
final val enum_days_SUNDAY = 6
26+
27+
final val enum_toggle_e_OFF = 0
28+
final val enum_toggle_e_ON = 1
29+
2830
}

0 commit comments

Comments
 (0)