Flutter Engine
The Flutter Engine
Macros | Functions | Variables
entrypoints_verification_test.cc File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "include/dart_api.h"
#include "include/dart_native_api.h"

Go to the source code of this file.

Macros

#define CHECK(H)
 
#define ASSERT(E)
 
#define FAIL(name, result)
 
#define FAIL_INVOKE_FIELD(name, result)
 

Functions

void Fail (const char *name, Dart_Handle result)
 
static void FailInvokeField (const char *name, Dart_Handle result)
 
static void FailClosurizeConstructor (const char *name, Dart_Handle result)
 
static void TestFields (Dart_Handle target)
 
DART_EXPORT void RunTests ()
 

Variables

static bool is_dart_precompiled_runtime = true
 

Macro Definition Documentation

◆ ASSERT

#define ASSERT (   E)
Value:
if (!(E)) { \
fprintf(stderr, "Assertion \"" #E "\" failed at %s:%d!\n", __FILE__, \
__LINE__); \
abort(); \
}

Definition at line 25 of file entrypoints_verification_test.cc.

◆ CHECK

#define CHECK (   H)
Value:
do { \
Dart_Handle __handle__ = H; \
if (Dart_IsError(__handle__)) { \
const char* message = Dart_GetError(__handle__); \
fprintf(stderr, "Check \"" #H "\" failed: %s", message); \
abort(); \
} \
} while (false)
#define H
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT const char * Dart_GetError(Dart_Handle handle)
Win32Message message
Definition: SkMD5.cpp:130

Definition at line 15 of file entrypoints_verification_test.cc.

◆ FAIL

#define FAIL (   name,
  result 
)
Value:
Fail(name, result); \
}
static bool is_dart_precompiled_runtime
GAsyncResult * result
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

Definition at line 36 of file entrypoints_verification_test.cc.

◆ FAIL_INVOKE_FIELD

#define FAIL_INVOKE_FIELD (   name,
  result 
)
Value:
FailInvokeField(name, result); \
}

Definition at line 48 of file entrypoints_verification_test.cc.

Function Documentation

◆ Fail()

void Fail ( const char *  name,
Dart_Handle  result 
)

Definition at line 41 of file entrypoints_verification_test.cc.

41 {
43 const char* error = Dart_GetError(result);
44 ASSERT(strstr(error, name));
45 ASSERT(strstr(error, "It is illegal to access"));
46}
DART_EXPORT bool Dart_IsApiError(Dart_Handle handle)
#define ASSERT(E)
const uint8_t uint32_t uint32_t GError ** error

◆ FailClosurizeConstructor()

static void FailClosurizeConstructor ( const char *  name,
Dart_Handle  result 
)
static

Definition at line 60 of file entrypoints_verification_test.cc.

60 {
62 const char* error = Dart_GetError(result);
63 ASSERT(strstr(error, name));
64 ASSERT(strstr(error, "No static getter"));
65}
DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle handle)

◆ FailInvokeField()

static void FailInvokeField ( const char *  name,
Dart_Handle  result 
)
static

Definition at line 53 of file entrypoints_verification_test.cc.

53 {
55 const char* error = Dart_GetError(result);
56 ASSERT(strstr(error, name));
57 ASSERT(strstr(error, "Entry-points do not allow invoking fields"));
58}

◆ RunTests()

DART_EXPORT void RunTests ( )

Definition at line 96 of file entrypoints_verification_test.cc.

96 {
98
100
101 //////// Test allocation and constructor invocation.
102
104
106 CHECK(D_class);
107
108 CHECK(Dart_Allocate(D_class));
109
110 FAIL("D.", Dart_New(D_class, Dart_Null(), 0, nullptr));
111
112 CHECK(Dart_New(D_class, Dart_NewStringFromCString("defined"), 0, nullptr));
113 Dart_Handle D =
114 Dart_New(D_class, Dart_NewStringFromCString("fact"), 0, nullptr);
115 CHECK(D);
116
117 //////// Test actions against methods
118
120 "defined", Dart_GetField(D_class, Dart_NewStringFromCString("defined")));
122 "fact", Dart_GetField(D_class, Dart_NewStringFromCString("fact")));
123
124 FAIL("fn0", Dart_Invoke(D, Dart_NewStringFromCString("fn0"), 0, nullptr));
125
126 CHECK(Dart_Invoke(D, Dart_NewStringFromCString("fn1"), 0, nullptr));
127 FAIL("fn1", Dart_Invoke(D, Dart_NewStringFromCString("fn1_get"), 0, nullptr));
128 CHECK(Dart_Invoke(D, Dart_NewStringFromCString("fn1_call"), 0, nullptr));
129
131
134 FAIL("fn1", Dart_GetField(D, Dart_NewStringFromCString("fn1_call")));
135
136 FAIL("fn2",
137 Dart_Invoke(D_class, Dart_NewStringFromCString("fn2"), 0, nullptr));
138
139 CHECK(Dart_Invoke(D_class, Dart_NewStringFromCString("fn3"), 0, nullptr));
140 CHECK(
141 Dart_Invoke(D_class, Dart_NewStringFromCString("fn3_call"), 0, nullptr));
142 FAIL("fn3",
143 Dart_Invoke(D_class, Dart_NewStringFromCString("fn3_get"), 0, nullptr));
144
145 FAIL("fn2", Dart_GetField(D_class, Dart_NewStringFromCString("fn2")));
146
148 FAIL("fn3_call",
149 Dart_GetField(D_class, Dart_NewStringFromCString("fn3_call")));
150 CHECK(Dart_GetField(D_class, Dart_NewStringFromCString("fn3_get")));
151
152 FAIL("fn0", Dart_Invoke(lib, Dart_NewStringFromCString("fn0"), 0, nullptr));
153
154 CHECK(Dart_Invoke(lib, Dart_NewStringFromCString("fn1"), 0, nullptr));
155 FAIL("fn1",
156 Dart_Invoke(lib, Dart_NewStringFromCString("fn1_get"), 0, nullptr));
157 CHECK(Dart_Invoke(lib, Dart_NewStringFromCString("fn1_call"), 0, nullptr));
158
159 FAIL("fn0", Dart_GetField(lib, Dart_NewStringFromCString("fn0")));
160
163 FAIL("fn1", Dart_GetField(lib, Dart_NewStringFromCString("fn1_call")));
164
165 //////// Test actions against fields
166
167 TestFields(D);
168
170 TestFields(F_class);
171
172 TestFields(lib);
173}
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_Allocate(Dart_Handle type)
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_Invoke(Dart_Handle target, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT bool Dart_IsPrecompiledRuntime(void)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_New(Dart_Handle type, Dart_Handle constructor_name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT Dart_Handle Dart_Null(void)
DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle class_name)
DART_EXPORT Dart_Handle Dart_NewStringFromCString(const char *str)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_GetField(Dart_Handle container, Dart_Handle name)
DART_EXPORT Dart_Handle Dart_RootLibrary(void)
static void FailClosurizeConstructor(const char *name, Dart_Handle result)
#define FAIL(name, result)
static void TestFields(Dart_Handle target)
#define CHECK(H)

◆ TestFields()

static void TestFields ( Dart_Handle  target)
static

Definition at line 67 of file entrypoints_verification_test.cc.

67 {
69 FAIL("fld0",
71
73 "fld0",
74 Dart_Invoke(target, Dart_NewStringFromCString("fld0"), 0, nullptr));
75
79 "fld1",
80 Dart_Invoke(target, Dart_NewStringFromCString("fld1"), 0, nullptr));
81
83 FAIL("fld2",
86 "fld2",
87 Dart_Invoke(target, Dart_NewStringFromCString("fld2"), 0, nullptr));
88
92 "fld3",
93 Dart_Invoke(target, Dart_NewStringFromCString("fld3"), 0, nullptr));
94}
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SetField(Dart_Handle container, Dart_Handle name, Dart_Handle value)
#define FAIL_INVOKE_FIELD(name, result)
uint32_t * target

Variable Documentation

◆ is_dart_precompiled_runtime

bool is_dart_precompiled_runtime = true
static

Definition at line 32 of file entrypoints_verification_test.cc.