Skip to content

Commit

Permalink
#993. Wrong annotation tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Apr 22, 2021
1 parent 6d4610f commit 13f010c
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 0 deletions.
58 changes: 58 additions & 0 deletions LibTest/ffi/Struct/wrong_annotation_A01_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*/
/**
* @assertion All field declarations in a Struct subclass declaration must
* either have type int or float and be annotated with a NativeType representing
* the native type, or must be of type Pointer.
*
* @description Checks that it is a compile error if double field is annotated
* as IntX
* @author sgrekhov@unipro.ru
*/
import "dart:ffi";

class S1 extends Struct {
@Int8()
//^^^^^^^
// [analyzer] unspecified
external double x;
// ^
// [cfe] unspecified
}

class S2 extends Struct {
@Int16()
//^^^^^^^^
// [analyzer] unspecified
external double x;
// ^
// [cfe] unspecified
}

class S3 extends Struct {
@Int32()
//^^^^^^^^
// [analyzer] unspecified
external double x;
// ^
// [cfe] unspecified
}

class S4 extends Struct {
@Int64()
//^^^^^^^^
// [analyzer] unspecified
external double x;
// ^
// [cfe] unspecified
}

void main() {
S1? s1;
S2? s2;
S3? s3;
S4? s4;
}
58 changes: 58 additions & 0 deletions LibTest/ffi/Struct/wrong_annotation_A01_t02.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*/
/**
* @assertion All field declarations in a Struct subclass declaration must
* either have type int or float and be annotated with a NativeType representing
* the native type, or must be of type Pointer.
*
* @description Checks that it is a compile error if double field is annotated
* as UIntX
* @author sgrekhov@unipro.ru
*/
import "dart:ffi";

class S1 extends Struct {
@Uint8()
//^^^^^^^^
// [analyzer] unspecified
external double x;
// ^
// [cfe] unspecified
}

class S2 extends Struct {
@Uint16()
//^^^^^^^^^
// [analyzer] unspecified
external double x;
// ^
// [cfe] unspecified
}

class S3 extends Struct {
@Uint32()
//^^^^^^^^^
// [analyzer] unspecified
external double x;
// ^
// [cfe] unspecified
}

class S4 extends Struct {
@Uint64()
//^^^^^^^^^
// [analyzer] unspecified
external double x;
// ^
// [cfe] unspecified
}

void main() {
S1? s1;
S2? s2;
S3? s3;
S4? s4;
}
38 changes: 38 additions & 0 deletions LibTest/ffi/Struct/wrong_annotation_A01_t03.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*/
/**
* @assertion All field declarations in a Struct subclass declaration must
* either have type int or float and be annotated with a NativeType representing
* the native type, or must be of type Pointer.
*
* @description Checks that it is a compile error if int field is annotated
* as Float or Double
* @author sgrekhov@unipro.ru
*/
import "dart:ffi";

class S1 extends Struct {
@Double()
//^^^^^^^^^
// [analyzer] unspecified
external int x;
// ^
// [cfe] unspecified
}

class S2 extends Struct {
@Float()
//^^^^^^^^^
// [analyzer] unspecified
external int x;
// ^
// [cfe] unspecified
}

void main() {
S1? s1;
S2? s2;
}
38 changes: 38 additions & 0 deletions LibTest/ffi/Struct/wrong_annotation_A01_t04.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*/
/**
* @assertion All field declarations in a Struct subclass declaration must
* either have type int or float and be annotated with a NativeType representing
* the native type, or must be of type Pointer.
*
* @description Checks that it is a compile error if field is annotated
* as Void
* @author sgrekhov@unipro.ru
*/
import "dart:ffi";

class S1 extends Struct {
@Void()
//^^^^^^^
// [analyzer] unspecified
external int x;
// ^
// [cfe] unspecified
}

class S2 extends Struct {
@Void()
//^^^^^^^
// [analyzer] unspecified
external double x;
// ^
// [cfe] unspecified
}

void main() {
S1? s1;
S2? s2;
}
38 changes: 38 additions & 0 deletions LibTest/ffi/Struct/wrong_annotation_A01_t05.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*/
/**
* @assertion All field declarations in a Struct subclass declaration must
* either have type int or float and be annotated with a NativeType representing
* the native type, or must be of type Pointer.
*
* @description Checks that it is a compile error if double field is annotated
* as IntPtr
* @author sgrekhov@unipro.ru
*/
import "dart:ffi";

class S1 extends Struct {
@IntPtr()
//^^^^^^^^^
// [analyzer] unspecified
external double x;
// ^
// [cfe] unspecified
}

class S2 extends Struct {
@IntPtr()
//^^^^^^^^^
// [analyzer] unspecified
external double x;
// ^
// [cfe] unspecified
}

void main() {
S1? s1;
S2? s2;
}
38 changes: 38 additions & 0 deletions LibTest/ffi/Struct/wrong_annotation_A01_t06.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*/
/**
* @assertion All field declarations in a Struct subclass declaration must
* either have type int or float and be annotated with a NativeType representing
* the native type, or must be of type Pointer.
*
* @description Checks that it is a compile error if double field is annotated
* as NativeType
* @author sgrekhov@unipro.ru
*/
import "dart:ffi";

class S1 extends Struct {
@NativeType()
//^^^^^^^^^^^^^
// [analyzer] unspecified
external double x;
// ^
// [cfe] unspecified
}

class S2 extends Struct {
@NativeType()
//^^^^^^^^^^^^^
// [analyzer] unspecified
external int x;
// ^
// [cfe] unspecified
}

void main() {
S1? s1;
S2? s2;
}

0 comments on commit 13f010c

Please sign in to comment.