Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 11411271: Remove support for interfaces. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/flow_graph_compiler_ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "platform/json.h" 7 #include "platform/json.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 EXPECT_VALID( 2372 EXPECT_VALID(
2373 Dart_FunctionParameterCounts(sig_func, &fixed_params, &opt_params)); 2373 Dart_FunctionParameterCounts(sig_func, &fixed_params, &opt_params));
2374 EXPECT_EQ(1, fixed_params); 2374 EXPECT_EQ(1, fixed_params);
2375 EXPECT_EQ(0, opt_params); 2375 EXPECT_EQ(0, opt_params);
2376 2376
2377 // Pass the wrong class kind to Dart_ClassGetFunctionTypeSignature 2377 // Pass the wrong class kind to Dart_ClassGetFunctionTypeSignature
2378 EXPECT_ERROR(Dart_ClassGetFunctionTypeSignature(normal_cls), 2378 EXPECT_ERROR(Dart_ClassGetFunctionTypeSignature(normal_cls),
2379 "class 'SomeClass' is not a function-type class."); 2379 "class 'SomeClass' is not a function-type class.");
2380 } 2380 }
2381 2381
2382 #define CHECK_INTERFACE(handle, name) \ 2382 #define CHECK_ABSTRACT_CLASS(handle, name) \
2383 { \ 2383 { \
2384 Dart_Handle tmp = (handle); \ 2384 Dart_Handle tmp = (handle); \
2385 EXPECT_VALID(tmp); \ 2385 EXPECT_VALID(tmp); \
2386 EXPECT(Dart_IsInterface(tmp)); \ 2386 EXPECT(Dart_IsAbstractClass(tmp)); \
2387 Dart_Handle intf_name = Dart_ClassName(tmp); \ 2387 Dart_Handle intf_name = Dart_ClassName(tmp); \
2388 EXPECT_VALID(intf_name); \ 2388 EXPECT_VALID(intf_name); \
2389 const char* intf_name_cstr = ""; \ 2389 const char* intf_name_cstr = ""; \
2390 EXPECT_VALID(Dart_StringToCString(intf_name, &intf_name_cstr)); \ 2390 EXPECT_VALID(Dart_StringToCString(intf_name, &intf_name_cstr)); \
2391 EXPECT_STREQ((name), intf_name_cstr); \ 2391 EXPECT_STREQ((name), intf_name_cstr); \
2392 } 2392 }
2393 2393
2394 2394
2395 TEST_CASE(ClassGetInterfaces) { 2395 TEST_CASE(ClassGetInterfaces) {
2396 const char* kScriptChars = 2396 const char* kScriptChars =
2397 "class MyClass0 {\n" 2397 "class MyClass0 {\n"
2398 "}\n" 2398 "}\n"
2399 "\n" 2399 "\n"
2400 "class MyClass1 implements MyInterface1 {\n" 2400 "class MyClass1 implements MyInterface1 {\n"
2401 "}\n" 2401 "}\n"
2402 "\n" 2402 "\n"
2403 "class MyClass2 implements MyInterface0, MyInterface1 {\n" 2403 "class MyClass2 implements MyInterface0, MyInterface1 {\n"
2404 "}\n" 2404 "}\n"
2405 "\n" 2405 "\n"
2406 "interface MyInterface0 {\n" 2406 "abstract class MyInterface0 {\n"
2407 "}\n" 2407 "}\n"
2408 "\n" 2408 "\n"
2409 "interface MyInterface1 extends MyInterface0 {\n" 2409 "abstract class MyInterface1 implements MyInterface0 {\n"
2410 "}\n"; 2410 "}\n";
2411 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 2411 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
2412 2412
2413 Dart_Handle cls0 = Dart_GetClass(lib, NewString("MyClass0")); 2413 Dart_Handle cls0 = Dart_GetClass(lib, NewString("MyClass0"));
2414 Dart_Handle cls1 = Dart_GetClass(lib, NewString("MyClass1")); 2414 Dart_Handle cls1 = Dart_GetClass(lib, NewString("MyClass1"));
2415 Dart_Handle cls2 = Dart_GetClass(lib, NewString("MyClass2")); 2415 Dart_Handle cls2 = Dart_GetClass(lib, NewString("MyClass2"));
2416 Dart_Handle intf0 = Dart_GetClass(lib, NewString("MyInterface0")); 2416 Dart_Handle intf0 = Dart_GetClass(lib, NewString("MyInterface0"));
2417 Dart_Handle intf1 = Dart_GetClass(lib, NewString("MyInterface1")); 2417 Dart_Handle intf1 = Dart_GetClass(lib, NewString("MyInterface1"));
2418 2418
2419 intptr_t len = -1; 2419 intptr_t len = -1;
2420 EXPECT_VALID(Dart_ClassGetInterfaceCount(cls0, &len)); 2420 EXPECT_VALID(Dart_ClassGetInterfaceCount(cls0, &len));
2421 EXPECT_EQ(0, len); 2421 EXPECT_EQ(0, len);
2422 2422
2423 EXPECT_ERROR(Dart_ClassGetInterfaceAt(cls0, 0), 2423 EXPECT_ERROR(Dart_ClassGetInterfaceAt(cls0, 0),
2424 "Dart_ClassGetInterfaceAt: argument 'index' out of bounds"); 2424 "Dart_ClassGetInterfaceAt: argument 'index' out of bounds");
2425 2425
2426 len = -1; 2426 len = -1;
2427 EXPECT_VALID(Dart_ClassGetInterfaceCount(cls1, &len)); 2427 EXPECT_VALID(Dart_ClassGetInterfaceCount(cls1, &len));
2428 EXPECT_EQ(1, len); 2428 EXPECT_EQ(1, len);
2429 CHECK_INTERFACE(Dart_ClassGetInterfaceAt(cls1, 0), "MyInterface1"); 2429 CHECK_ABSTRACT_CLASS(Dart_ClassGetInterfaceAt(cls1, 0), "MyInterface1");
2430 2430
2431 EXPECT_ERROR(Dart_ClassGetInterfaceAt(cls1, -1), 2431 EXPECT_ERROR(Dart_ClassGetInterfaceAt(cls1, -1),
2432 "Dart_ClassGetInterfaceAt: argument 'index' out of bounds"); 2432 "Dart_ClassGetInterfaceAt: argument 'index' out of bounds");
2433 EXPECT_ERROR(Dart_ClassGetInterfaceAt(cls1, 1), 2433 EXPECT_ERROR(Dart_ClassGetInterfaceAt(cls1, 1),
2434 "Dart_ClassGetInterfaceAt: argument 'index' out of bounds"); 2434 "Dart_ClassGetInterfaceAt: argument 'index' out of bounds");
2435 2435
2436 len = -1; 2436 len = -1;
2437 EXPECT_VALID(Dart_ClassGetInterfaceCount(cls2, &len)); 2437 EXPECT_VALID(Dart_ClassGetInterfaceCount(cls2, &len));
2438 EXPECT_EQ(2, len); 2438 EXPECT_EQ(2, len);
2439 2439
2440 // TODO(turnidge): The test relies on the ordering here. Sort this. 2440 // TODO(turnidge): The test relies on the ordering here. Sort this.
2441 CHECK_INTERFACE(Dart_ClassGetInterfaceAt(cls2, 0), "MyInterface0"); 2441 CHECK_ABSTRACT_CLASS(Dart_ClassGetInterfaceAt(cls2, 0), "MyInterface0");
2442 CHECK_INTERFACE(Dart_ClassGetInterfaceAt(cls2, 1), "MyInterface1"); 2442 CHECK_ABSTRACT_CLASS(Dart_ClassGetInterfaceAt(cls2, 1), "MyInterface1");
2443 2443
2444 len = -1; 2444 len = -1;
2445 EXPECT_VALID(Dart_ClassGetInterfaceCount(intf0, &len)); 2445 EXPECT_VALID(Dart_ClassGetInterfaceCount(intf0, &len));
2446 EXPECT_EQ(0, len); 2446 EXPECT_EQ(0, len);
2447 2447
2448 len = -1; 2448 len = -1;
2449 EXPECT_VALID(Dart_ClassGetInterfaceCount(intf1, &len)); 2449 EXPECT_VALID(Dart_ClassGetInterfaceCount(intf1, &len));
2450 EXPECT_EQ(1, len); 2450 EXPECT_EQ(1, len);
2451 CHECK_INTERFACE(Dart_ClassGetInterfaceAt(intf1, 0), "MyInterface0"); 2451 CHECK_ABSTRACT_CLASS(Dart_ClassGetInterfaceAt(intf1, 0), "MyInterface0");
2452 2452
2453 // Error cases. 2453 // Error cases.
2454 EXPECT_ERROR(Dart_ClassGetInterfaceCount(Dart_True(), &len), 2454 EXPECT_ERROR(Dart_ClassGetInterfaceCount(Dart_True(), &len),
2455 "Dart_ClassGetInterfaceCount expects argument 'clazz' to be of " 2455 "Dart_ClassGetInterfaceCount expects argument 'clazz' to be of "
2456 "type Class."); 2456 "type Class.");
2457 EXPECT_ERROR(Dart_ClassGetInterfaceCount(Dart_NewApiError("MyError"), &len), 2457 EXPECT_ERROR(Dart_ClassGetInterfaceCount(Dart_NewApiError("MyError"), &len),
2458 "MyError"); 2458 "MyError");
2459 } 2459 }
2460 2460
2461 2461
(...skipping 4876 matching lines...) Expand 10 before | Expand all | Expand 10 after
7338 Dart_LoadSource(TestCase::lib(), url, source); 7338 Dart_LoadSource(TestCase::lib(), url, source);
7339 7339
7340 dart_args[0] = Dart_NewInteger(1); 7340 dart_args[0] = Dart_NewInteger(1);
7341 result = Dart_Invoke(lib1, NewString("start"), 1, dart_args); 7341 result = Dart_Invoke(lib1, NewString("start"), 1, dart_args);
7342 EXPECT_VALID(result); 7342 EXPECT_VALID(result);
7343 } 7343 }
7344 7344
7345 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 7345 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
7346 7346
7347 } // namespace dart 7347 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/flow_graph_compiler_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698