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

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

Issue 10883071: - Change "static final" to "static const" in the runtime/ directory. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months 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/lib/regexp_patch.dart ('k') | runtime/vm/parser.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 2526 matching lines...) Expand 10 before | Expand all | Expand 10 after
2537 " static_getset_fld = 'static getset';\n" 2537 " static_getset_fld = 'static getset';\n"
2538 " _static_getset_fld = 'hidden static getset';\n" 2538 " _static_getset_fld = 'hidden static getset';\n"
2539 " }\n" 2539 " }\n"
2540 "\n" 2540 "\n"
2541 " var instance_fld;\n" 2541 " var instance_fld;\n"
2542 " var _instance_fld;\n" 2542 " var _instance_fld;\n"
2543 " final final_instance_fld;\n" 2543 " final final_instance_fld;\n"
2544 " final _final_instance_fld;\n" 2544 " final _final_instance_fld;\n"
2545 " static var static_fld;\n" 2545 " static var static_fld;\n"
2546 " static var _static_fld;\n" 2546 " static var _static_fld;\n"
2547 " static final final_static_fld = 'final static';\n" 2547 " static const const_static_fld = 'const static';\n"
2548 " static final _final_static_fld = 'hidden final static';\n" 2548 " static const _const_static_fld = 'hidden const static';\n"
2549 "\n" 2549 "\n"
2550 " get instance_getset_fld() { return _gs_fld1; }\n" 2550 " get instance_getset_fld() { return _gs_fld1; }\n"
2551 " void set instance_getset_fld(var value) { _gs_fld1 = value; }\n" 2551 " void set instance_getset_fld(var value) { _gs_fld1 = value; }\n"
2552 " get _instance_getset_fld() { return _gs_fld2; }\n" 2552 " get _instance_getset_fld() { return _gs_fld2; }\n"
2553 " void set _instance_getset_fld(var value) { _gs_fld2 = value; }\n" 2553 " void set _instance_getset_fld(var value) { _gs_fld2 = value; }\n"
2554 " var _gs_fld1;\n" 2554 " var _gs_fld1;\n"
2555 " var _gs_fld2;\n" 2555 " var _gs_fld2;\n"
2556 "\n" 2556 "\n"
2557 " static get static_getset_fld() { return _gs_fld3; }\n" 2557 " static get static_getset_fld() { return _gs_fld3; }\n"
2558 " static void set static_getset_fld(var value) { _gs_fld3 = value; }\n" 2558 " static void set static_getset_fld(var value) { _gs_fld3 = value; }\n"
2559 " static get _static_getset_fld() { return _gs_fld4; }\n" 2559 " static get _static_getset_fld() { return _gs_fld4; }\n"
2560 " static void set _static_getset_fld(var value) { _gs_fld4 = value; }\n" 2560 " static void set _static_getset_fld(var value) { _gs_fld4 = value; }\n"
2561 " static var _gs_fld3;\n" 2561 " static var _gs_fld3;\n"
2562 " static var _gs_fld4;\n" 2562 " static var _gs_fld4;\n"
2563 "}\n" 2563 "}\n"
2564 "var top_fld;\n" 2564 "var top_fld;\n"
2565 "var _top_fld;\n" 2565 "var _top_fld;\n"
2566 "final final_top_fld = 'final top';\n" 2566 "const const_top_fld = 'const top';\n"
2567 "final _final_top_fld = 'hidden final top';\n" 2567 "const _const_top_fld = 'hidden const top';\n"
2568 "\n" 2568 "\n"
2569 "get top_getset_fld() { return _gs_fld5; }\n" 2569 "get top_getset_fld() { return _gs_fld5; }\n"
2570 "void set top_getset_fld(var value) { _gs_fld5 = value; }\n" 2570 "void set top_getset_fld(var value) { _gs_fld5 = value; }\n"
2571 "get _top_getset_fld() { return _gs_fld6; }\n" 2571 "get _top_getset_fld() { return _gs_fld6; }\n"
2572 "void set _top_getset_fld(var value) { _gs_fld6 = value; }\n" 2572 "void set _top_getset_fld(var value) { _gs_fld6 = value; }\n"
2573 "var _gs_fld5;\n" 2573 "var _gs_fld5;\n"
2574 "var _gs_fld6;\n" 2574 "var _gs_fld6;\n"
2575 "\n" 2575 "\n"
2576 "Fields test() {\n" 2576 "Fields test() {\n"
2577 " Fields.Init();\n" 2577 " Fields.Init();\n"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 TestFieldNotFound(instance, name); 2662 TestFieldNotFound(instance, name);
2663 TestFieldOk(cls, name, false, "static"); 2663 TestFieldOk(cls, name, false, "static");
2664 2664
2665 // Hidden static field. 2665 // Hidden static field.
2666 name = Dart_NewString("_static_fld"); 2666 name = Dart_NewString("_static_fld");
2667 TestFieldNotFound(lib, name); 2667 TestFieldNotFound(lib, name);
2668 TestFieldNotFound(instance, name); 2668 TestFieldNotFound(instance, name);
2669 TestFieldOk(cls, name, false, "hidden static"); 2669 TestFieldOk(cls, name, false, "hidden static");
2670 2670
2671 // Static final field. 2671 // Static final field.
2672 name = Dart_NewString("final_static_fld"); 2672 name = Dart_NewString("const_static_fld");
2673 TestFieldNotFound(lib, name); 2673 TestFieldNotFound(lib, name);
2674 TestFieldNotFound(instance, name); 2674 TestFieldNotFound(instance, name);
2675 TestFieldOk(cls, name, true, "final static"); 2675 TestFieldOk(cls, name, true, "const static");
2676 2676
2677 // Hidden static final field. 2677 // Hidden static const field.
2678 name = Dart_NewString("_final_static_fld"); 2678 name = Dart_NewString("_const_static_fld");
2679 TestFieldNotFound(lib, name); 2679 TestFieldNotFound(lib, name);
2680 TestFieldNotFound(instance, name); 2680 TestFieldNotFound(instance, name);
2681 TestFieldOk(cls, name, true, "hidden final static"); 2681 TestFieldOk(cls, name, true, "hidden const static");
2682 2682
2683 // Static non-inherited field. Not found at any level. 2683 // Static non-inherited field. Not found at any level.
2684 name = Dart_NewString("non_inherited_fld"); 2684 name = Dart_NewString("non_inherited_fld");
2685 TestFieldNotFound(lib, name); 2685 TestFieldNotFound(lib, name);
2686 TestFieldNotFound(instance, name); 2686 TestFieldNotFound(instance, name);
2687 TestFieldNotFound(cls, name); 2687 TestFieldNotFound(cls, name);
2688 2688
2689 // Static get/set field. 2689 // Static get/set field.
2690 name = Dart_NewString("static_getset_fld"); 2690 name = Dart_NewString("static_getset_fld");
2691 TestFieldNotFound(lib, name); 2691 TestFieldNotFound(lib, name);
(...skipping 12 matching lines...) Expand all
2704 TestFieldNotFound(instance, name); 2704 TestFieldNotFound(instance, name);
2705 TestFieldOk(lib, name, false, "top"); 2705 TestFieldOk(lib, name, false, "top");
2706 2706
2707 // Hidden top-level field. 2707 // Hidden top-level field.
2708 name = Dart_NewString("_top_fld"); 2708 name = Dart_NewString("_top_fld");
2709 TestFieldNotFound(cls, name); 2709 TestFieldNotFound(cls, name);
2710 TestFieldNotFound(instance, name); 2710 TestFieldNotFound(instance, name);
2711 TestFieldOk(lib, name, false, "hidden top"); 2711 TestFieldOk(lib, name, false, "hidden top");
2712 2712
2713 // Top-Level final field. 2713 // Top-Level final field.
2714 name = Dart_NewString("final_top_fld"); 2714 name = Dart_NewString("const_top_fld");
2715 TestFieldNotFound(cls, name); 2715 TestFieldNotFound(cls, name);
2716 TestFieldNotFound(instance, name); 2716 TestFieldNotFound(instance, name);
2717 TestFieldOk(lib, name, true, "final top"); 2717 TestFieldOk(lib, name, true, "const top");
2718 2718
2719 // Hidden top-level final field. 2719 // Hidden top-level final field.
2720 name = Dart_NewString("_final_top_fld"); 2720 name = Dart_NewString("_const_top_fld");
2721 TestFieldNotFound(cls, name); 2721 TestFieldNotFound(cls, name);
2722 TestFieldNotFound(instance, name); 2722 TestFieldNotFound(instance, name);
2723 TestFieldOk(lib, name, true, "hidden final top"); 2723 TestFieldOk(lib, name, true, "hidden const top");
2724 2724
2725 // Top-Level get/set field. 2725 // Top-Level get/set field.
2726 name = Dart_NewString("top_getset_fld"); 2726 name = Dart_NewString("top_getset_fld");
2727 TestFieldNotFound(cls, name); 2727 TestFieldNotFound(cls, name);
2728 TestFieldNotFound(instance, name); 2728 TestFieldNotFound(instance, name);
2729 TestFieldOk(lib, name, false, "top getset"); 2729 TestFieldOk(lib, name, false, "top getset");
2730 2730
2731 // Hidden top-level get/set field. 2731 // Hidden top-level get/set field.
2732 name = Dart_NewString("_top_getset_fld"); 2732 name = Dart_NewString("_top_getset_fld");
2733 TestFieldNotFound(cls, name); 2733 TestFieldNotFound(cls, name);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2806 } 2806 }
2807 2807
2808 2808
2809 TEST_CASE(InjectNativeFields1) { 2809 TEST_CASE(InjectNativeFields1) {
2810 const char* kScriptChars = 2810 const char* kScriptChars =
2811 "class NativeFields extends NativeFieldsWrapper {\n" 2811 "class NativeFields extends NativeFieldsWrapper {\n"
2812 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" 2812 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n"
2813 " int fld1;\n" 2813 " int fld1;\n"
2814 " final int fld2;\n" 2814 " final int fld2;\n"
2815 " static int fld3;\n" 2815 " static int fld3;\n"
2816 " static final int fld4 = 10;\n" 2816 " static const int fld4 = 10;\n"
2817 "}\n" 2817 "}\n"
2818 "NativeFields testMain() {\n" 2818 "NativeFields testMain() {\n"
2819 " NativeFields obj = new NativeFields(10, 20);\n" 2819 " NativeFields obj = new NativeFields(10, 20);\n"
2820 " return obj;\n" 2820 " return obj;\n"
2821 "}\n"; 2821 "}\n";
2822 Dart_Handle result; 2822 Dart_Handle result;
2823 2823
2824 const int kNumNativeFields = 4; 2824 const int kNumNativeFields = 4;
2825 2825
2826 // Create a test library. 2826 // Create a test library.
(...skipping 28 matching lines...) Expand all
2855 } 2855 }
2856 2856
2857 2857
2858 TEST_CASE(InjectNativeFields2) { 2858 TEST_CASE(InjectNativeFields2) {
2859 const char* kScriptChars = 2859 const char* kScriptChars =
2860 "class NativeFields extends NativeFieldsWrapper {\n" 2860 "class NativeFields extends NativeFieldsWrapper {\n"
2861 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" 2861 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n"
2862 " int fld1;\n" 2862 " int fld1;\n"
2863 " final int fld2;\n" 2863 " final int fld2;\n"
2864 " static int fld3;\n" 2864 " static int fld3;\n"
2865 " static final int fld4 = 10;\n" 2865 " static const int fld4 = 10;\n"
2866 "}\n" 2866 "}\n"
2867 "NativeFields testMain() {\n" 2867 "NativeFields testMain() {\n"
2868 " NativeFields obj = new NativeFields(10, 20);\n" 2868 " NativeFields obj = new NativeFields(10, 20);\n"
2869 " return obj;\n" 2869 " return obj;\n"
2870 "}\n"; 2870 "}\n";
2871 Dart_Handle result; 2871 Dart_Handle result;
2872 // Create a test library and Load up a test script in it. 2872 // Create a test library and Load up a test script in it.
2873 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 2873 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
2874 2874
2875 // Invoke a function which returns an object of type NativeFields. 2875 // Invoke a function which returns an object of type NativeFields.
2876 result = Dart_Invoke(lib, Dart_NewString("testMain"), 0, NULL); 2876 result = Dart_Invoke(lib, Dart_NewString("testMain"), 0, NULL);
2877 2877
2878 // We expect this to fail as class "NativeFields" extends 2878 // We expect this to fail as class "NativeFields" extends
2879 // "NativeFieldsWrapper" and there is no definition of it either 2879 // "NativeFieldsWrapper" and there is no definition of it either
2880 // in the dart code or through the native field injection mechanism. 2880 // in the dart code or through the native field injection mechanism.
2881 EXPECT(Dart_IsError(result)); 2881 EXPECT(Dart_IsError(result));
2882 } 2882 }
2883 2883
2884 2884
2885 TEST_CASE(InjectNativeFields3) { 2885 TEST_CASE(InjectNativeFields3) {
2886 const char* kScriptChars = 2886 const char* kScriptChars =
2887 "#import('dart:nativewrappers');" 2887 "#import('dart:nativewrappers');"
2888 "class NativeFields extends NativeFieldWrapperClass2 {\n" 2888 "class NativeFields extends NativeFieldWrapperClass2 {\n"
2889 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" 2889 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n"
2890 " int fld1;\n" 2890 " int fld1;\n"
2891 " final int fld2;\n" 2891 " final int fld2;\n"
2892 " static int fld3;\n" 2892 " static int fld3;\n"
2893 " static final int fld4 = 10;\n" 2893 " static const int fld4 = 10;\n"
2894 "}\n" 2894 "}\n"
2895 "NativeFields testMain() {\n" 2895 "NativeFields testMain() {\n"
2896 " NativeFields obj = new NativeFields(10, 20);\n" 2896 " NativeFields obj = new NativeFields(10, 20);\n"
2897 " return obj;\n" 2897 " return obj;\n"
2898 "}\n"; 2898 "}\n";
2899 Dart_Handle result; 2899 Dart_Handle result;
2900 const int kNumNativeFields = 2; 2900 const int kNumNativeFields = 2;
2901 2901
2902 // Load up a test script in the test library. 2902 // Load up a test script in the test library.
2903 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, 2903 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars,
(...skipping 20 matching lines...) Expand all
2924 2924
2925 2925
2926 TEST_CASE(InjectNativeFields4) { 2926 TEST_CASE(InjectNativeFields4) {
2927 const char* kScriptChars = 2927 const char* kScriptChars =
2928 "#import('dart:nativewrappers');" 2928 "#import('dart:nativewrappers');"
2929 "class NativeFields extends NativeFieldWrapperClass2 {\n" 2929 "class NativeFields extends NativeFieldWrapperClass2 {\n"
2930 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" 2930 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n"
2931 " int fld1;\n" 2931 " int fld1;\n"
2932 " final int fld2;\n" 2932 " final int fld2;\n"
2933 " static int fld3;\n" 2933 " static int fld3;\n"
2934 " static final int fld4 = 10;\n" 2934 " static const int fld4 = 10;\n"
2935 "}\n" 2935 "}\n"
2936 "NativeFields testMain() {\n" 2936 "NativeFields testMain() {\n"
2937 " NativeFields obj = new NativeFields(10, 20);\n" 2937 " NativeFields obj = new NativeFields(10, 20);\n"
2938 " return obj;\n" 2938 " return obj;\n"
2939 "}\n"; 2939 "}\n";
2940 Dart_Handle result; 2940 Dart_Handle result;
2941 // Load up a test script in the test library. 2941 // Load up a test script in the test library.
2942 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 2942 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
2943 2943
2944 // Invoke a function which returns an object of type NativeFields. 2944 // Invoke a function which returns an object of type NativeFields.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
3036 3036
3037 3037
3038 TEST_CASE(NativeFieldAccess) { 3038 TEST_CASE(NativeFieldAccess) {
3039 const char* kScriptChars = 3039 const char* kScriptChars =
3040 "class NativeFields extends NativeFieldsWrapper {\n" 3040 "class NativeFields extends NativeFieldsWrapper {\n"
3041 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" 3041 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n"
3042 " int fld0;\n" 3042 " int fld0;\n"
3043 " int fld1;\n" 3043 " int fld1;\n"
3044 " final int fld2;\n" 3044 " final int fld2;\n"
3045 " static int fld3;\n" 3045 " static int fld3;\n"
3046 " static final int fld4 = 10;\n" 3046 " static const int fld4 = 10;\n"
3047 "}\n" 3047 "}\n"
3048 "NativeFields testMain() {\n" 3048 "NativeFields testMain() {\n"
3049 " NativeFields obj = new NativeFields(10, 20);\n" 3049 " NativeFields obj = new NativeFields(10, 20);\n"
3050 " return obj;\n" 3050 " return obj;\n"
3051 "}\n"; 3051 "}\n";
3052 const int kNumNativeFields = 4; 3052 const int kNumNativeFields = 4;
3053 3053
3054 // Create a test library. 3054 // Create a test library.
3055 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, 3055 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars,
3056 native_field_lookup); 3056 native_field_lookup);
(...skipping 30 matching lines...) Expand all
3087 3087
3088 TEST_CASE(ImplicitNativeFieldAccess) { 3088 TEST_CASE(ImplicitNativeFieldAccess) {
3089 const char* kScriptChars = 3089 const char* kScriptChars =
3090 "#import('dart:nativewrappers');" 3090 "#import('dart:nativewrappers');"
3091 "class NativeFields extends NativeFieldWrapperClass4 {\n" 3091 "class NativeFields extends NativeFieldWrapperClass4 {\n"
3092 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" 3092 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n"
3093 " int fld0;\n" 3093 " int fld0;\n"
3094 " int fld1;\n" 3094 " int fld1;\n"
3095 " final int fld2;\n" 3095 " final int fld2;\n"
3096 " static int fld3;\n" 3096 " static int fld3;\n"
3097 " static final int fld4 = 10;\n" 3097 " static const int fld4 = 10;\n"
3098 "}\n" 3098 "}\n"
3099 "NativeFields testMain() {\n" 3099 "NativeFields testMain() {\n"
3100 " NativeFields obj = new NativeFields(10, 20);\n" 3100 " NativeFields obj = new NativeFields(10, 20);\n"
3101 " return obj;\n" 3101 " return obj;\n"
3102 "}\n"; 3102 "}\n";
3103 // Load up a test script in the test library. 3103 // Load up a test script in the test library.
3104 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, 3104 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars,
3105 native_field_lookup); 3105 native_field_lookup);
3106 3106
3107 // Invoke a function which returns an object of type NativeFields. 3107 // Invoke a function which returns an object of type NativeFields.
3108 Dart_Handle retobj = Dart_Invoke(lib, Dart_NewString("testMain"), 0, NULL); 3108 Dart_Handle retobj = Dart_Invoke(lib, Dart_NewString("testMain"), 0, NULL);
3109 EXPECT_VALID(retobj); 3109 EXPECT_VALID(retobj);
3110 3110
3111 // Now access and set various instance fields of the returned object. 3111 // Now access and set various instance fields of the returned object.
3112 TestNativeFields(retobj); 3112 TestNativeFields(retobj);
3113 } 3113 }
3114 3114
3115 3115
3116 TEST_CASE(NegativeNativeFieldAccess) { 3116 TEST_CASE(NegativeNativeFieldAccess) {
3117 const char* kScriptChars = 3117 const char* kScriptChars =
3118 "class NativeFields {\n" 3118 "class NativeFields {\n"
3119 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" 3119 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n"
3120 " int fld1;\n" 3120 " int fld1;\n"
3121 " final int fld2;\n" 3121 " final int fld2;\n"
3122 " static int fld3;\n" 3122 " static int fld3;\n"
3123 " static final int fld4 = 10;\n" 3123 " static const int fld4 = 10;\n"
3124 "}\n" 3124 "}\n"
3125 "NativeFields testMain1() {\n" 3125 "NativeFields testMain1() {\n"
3126 " NativeFields obj = new NativeFields(10, 20);\n" 3126 " NativeFields obj = new NativeFields(10, 20);\n"
3127 " return obj;\n" 3127 " return obj;\n"
3128 "}\n" 3128 "}\n"
3129 "Function testMain2() {\n" 3129 "Function testMain2() {\n"
3130 " return function() {};\n" 3130 " return function() {};\n"
3131 "}\n"; 3131 "}\n";
3132 Dart_Handle result; 3132 Dart_Handle result;
3133 DARTSCOPE_NOCHECKS(Isolate::Current()); 3133 DARTSCOPE_NOCHECKS(Isolate::Current());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3180 result = Dart_SetNativeInstanceField(retobj, kNativeFld3, 40); 3180 result = Dart_SetNativeInstanceField(retobj, kNativeFld3, 40);
3181 EXPECT(Dart_IsError(result)); 3181 EXPECT(Dart_IsError(result));
3182 result = Dart_SetNativeInstanceField(retobj, kNativeFld0, 400); 3182 result = Dart_SetNativeInstanceField(retobj, kNativeFld0, 400);
3183 EXPECT(Dart_IsError(result)); 3183 EXPECT(Dart_IsError(result));
3184 } 3184 }
3185 3185
3186 3186
3187 TEST_CASE(GetStaticField_RunsInitializer) { 3187 TEST_CASE(GetStaticField_RunsInitializer) {
3188 const char* kScriptChars = 3188 const char* kScriptChars =
3189 "class TestClass {\n" 3189 "class TestClass {\n"
3190 " static final int fld1 = 7;\n" 3190 " static const int fld1 = 7;\n"
3191 " static int fld2 = 11;\n" 3191 " static int fld2 = 11;\n"
3192 " static void testMain() {\n" 3192 " static void testMain() {\n"
3193 " }\n" 3193 " }\n"
3194 "}\n"; 3194 "}\n";
3195 Dart_Handle result; 3195 Dart_Handle result;
3196 // Create a test library and Load up a test script in it. 3196 // Create a test library and Load up a test script in it.
3197 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 3197 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
3198 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("TestClass")); 3198 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("TestClass"));
3199 EXPECT_VALID(cls); 3199 EXPECT_VALID(cls);
3200 3200
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
3897 " Function method1(int i) {\n" 3897 " Function method1(int i) {\n"
3898 " f(int j) => j + i + fld1 + fld2 + fld4; \n" 3898 " f(int j) => j + i + fld1 + fld2 + fld4; \n"
3899 " return f;\n" 3899 " return f;\n"
3900 " }\n" 3900 " }\n"
3901 " static Function method2(int i) {\n" 3901 " static Function method2(int i) {\n"
3902 " n(int j) => true + i + fld4; \n" 3902 " n(int j) => true + i + fld4; \n"
3903 " return n;\n" 3903 " return n;\n"
3904 " }\n" 3904 " }\n"
3905 " int fld1;\n" 3905 " int fld1;\n"
3906 " final int fld2;\n" 3906 " final int fld2;\n"
3907 " static final int fld4 = 10;\n" 3907 " static const int fld4 = 10;\n"
3908 "}\n" 3908 "}\n"
3909 "Function testMain1() {\n" 3909 "Function testMain1() {\n"
3910 " InvokeClosure obj = new InvokeClosure(10, 20);\n" 3910 " InvokeClosure obj = new InvokeClosure(10, 20);\n"
3911 " return obj.method1(10);\n" 3911 " return obj.method1(10);\n"
3912 "}\n" 3912 "}\n"
3913 "Function testMain2() {\n" 3913 "Function testMain2() {\n"
3914 " return InvokeClosure.method2(10);\n" 3914 " return InvokeClosure.method2(10);\n"
3915 "}\n"; 3915 "}\n";
3916 Dart_Handle result; 3916 Dart_Handle result;
3917 DARTSCOPE_NOCHECKS(Isolate::Current()); 3917 DARTSCOPE_NOCHECKS(Isolate::Current());
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
4534 "var _b = '_b';\n" 4534 "var _b = '_b';\n"
4535 "final c = 'c';\n" 4535 "final c = 'c';\n"
4536 "final _d = '_d';\n" 4536 "final _d = '_d';\n"
4537 "class MyClass {\n" 4537 "class MyClass {\n"
4538 " var a = 'a';\n" 4538 " var a = 'a';\n"
4539 " var _b = '_b';\n" 4539 " var _b = '_b';\n"
4540 " final c = 'c';\n" 4540 " final c = 'c';\n"
4541 " final _d = '_d';\n" 4541 " final _d = '_d';\n"
4542 " static var e = 'e';\n" 4542 " static var e = 'e';\n"
4543 " static var _f = '_f';\n" 4543 " static var _f = '_f';\n"
4544 " static final g = 'g';\n" 4544 " static const g = 'g';\n"
4545 " static final _h = '_h';\n" 4545 " static const _h = '_h';\n"
4546 "}\n"; 4546 "}\n";
4547 4547
4548 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 4548 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
4549 EXPECT_VALID(lib); 4549 EXPECT_VALID(lib);
4550 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("MyClass")); 4550 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("MyClass"));
4551 EXPECT_VALID(cls); 4551 EXPECT_VALID(cls);
4552 TextBuffer buffer(128); 4552 TextBuffer buffer(128);
4553 4553
4554 // Lookup a top-level variable. 4554 // Lookup a top-level variable.
4555 Dart_Handle var = Dart_LookupVariable(lib, Dart_NewString("a")); 4555 Dart_Handle var = Dart_LookupVariable(lib, Dart_NewString("a"));
4556 EXPECT_VALID(var); 4556 EXPECT_VALID(var);
4557 EXPECT(Dart_IsVariable(var)); 4557 EXPECT(Dart_IsVariable(var));
4558 BuildVariableDescription(&buffer, var); 4558 BuildVariableDescription(&buffer, var);
4559 EXPECT_STREQ("a static", buffer.buf()); 4559 EXPECT_STREQ("a static", buffer.buf());
4560 4560
4561 // Lookup a private top-level variable. 4561 // Lookup a private top-level variable.
4562 var = Dart_LookupVariable(lib, Dart_NewString("_b")); 4562 var = Dart_LookupVariable(lib, Dart_NewString("_b"));
4563 EXPECT_VALID(var); 4563 EXPECT_VALID(var);
4564 EXPECT(Dart_IsVariable(var)); 4564 EXPECT(Dart_IsVariable(var));
4565 BuildVariableDescription(&buffer, var); 4565 BuildVariableDescription(&buffer, var);
4566 EXPECT_STREQ("_b static", buffer.buf()); 4566 EXPECT_STREQ("_b static", buffer.buf());
4567 4567
4568 // Lookup a final top-level variable. 4568 // Lookup a const top-level variable.
4569 var = Dart_LookupVariable(lib, Dart_NewString("c")); 4569 var = Dart_LookupVariable(lib, Dart_NewString("c"));
4570 EXPECT_VALID(var); 4570 EXPECT_VALID(var);
4571 EXPECT(Dart_IsVariable(var)); 4571 EXPECT(Dart_IsVariable(var));
4572 BuildVariableDescription(&buffer, var); 4572 BuildVariableDescription(&buffer, var);
4573 EXPECT_STREQ("c static final", buffer.buf()); 4573 EXPECT_STREQ("c static final", buffer.buf());
4574 4574
4575 // Lookup a private final top-level variable. 4575 // Lookup a private const top-level variable.
4576 var = Dart_LookupVariable(lib, Dart_NewString("_d")); 4576 var = Dart_LookupVariable(lib, Dart_NewString("_d"));
4577 EXPECT_VALID(var); 4577 EXPECT_VALID(var);
4578 EXPECT(Dart_IsVariable(var)); 4578 EXPECT(Dart_IsVariable(var));
4579 BuildVariableDescription(&buffer, var); 4579 BuildVariableDescription(&buffer, var);
4580 EXPECT_STREQ("_d static final", buffer.buf()); 4580 EXPECT_STREQ("_d static final", buffer.buf());
4581 4581
4582 // Lookup a instance variable. 4582 // Lookup a instance variable.
4583 var = Dart_LookupVariable(cls, Dart_NewString("a")); 4583 var = Dart_LookupVariable(cls, Dart_NewString("a"));
4584 EXPECT_VALID(var); 4584 EXPECT_VALID(var);
4585 EXPECT(Dart_IsVariable(var)); 4585 EXPECT(Dart_IsVariable(var));
(...skipping 28 matching lines...) Expand all
4614 BuildVariableDescription(&buffer, var); 4614 BuildVariableDescription(&buffer, var);
4615 EXPECT_STREQ("e static", buffer.buf()); 4615 EXPECT_STREQ("e static", buffer.buf());
4616 4616
4617 // Lookup a private static variable. 4617 // Lookup a private static variable.
4618 var = Dart_LookupVariable(cls, Dart_NewString("_f")); 4618 var = Dart_LookupVariable(cls, Dart_NewString("_f"));
4619 EXPECT_VALID(var); 4619 EXPECT_VALID(var);
4620 EXPECT(Dart_IsVariable(var)); 4620 EXPECT(Dart_IsVariable(var));
4621 BuildVariableDescription(&buffer, var); 4621 BuildVariableDescription(&buffer, var);
4622 EXPECT_STREQ("_f static", buffer.buf()); 4622 EXPECT_STREQ("_f static", buffer.buf());
4623 4623
4624 // Lookup a final static variable. 4624 // Lookup a const static variable.
4625 var = Dart_LookupVariable(cls, Dart_NewString("g")); 4625 var = Dart_LookupVariable(cls, Dart_NewString("g"));
4626 EXPECT_VALID(var); 4626 EXPECT_VALID(var);
4627 EXPECT(Dart_IsVariable(var)); 4627 EXPECT(Dart_IsVariable(var));
4628 BuildVariableDescription(&buffer, var); 4628 BuildVariableDescription(&buffer, var);
4629 EXPECT_STREQ("g static final", buffer.buf()); 4629 EXPECT_STREQ("g static final", buffer.buf());
4630 4630
4631 // Lookup a private final static variable. 4631 // Lookup a private const static variable.
4632 var = Dart_LookupVariable(cls, Dart_NewString("_h")); 4632 var = Dart_LookupVariable(cls, Dart_NewString("_h"));
4633 EXPECT_VALID(var); 4633 EXPECT_VALID(var);
4634 EXPECT(Dart_IsVariable(var)); 4634 EXPECT(Dart_IsVariable(var));
4635 BuildVariableDescription(&buffer, var); 4635 BuildVariableDescription(&buffer, var);
4636 EXPECT_STREQ("_h static final", buffer.buf()); 4636 EXPECT_STREQ("_h static final", buffer.buf());
4637 4637
4638 // Lookup a variable that does not exist from a library. 4638 // Lookup a variable that does not exist from a library.
4639 var = Dart_LookupVariable(lib, Dart_NewString("DoesNotExist")); 4639 var = Dart_LookupVariable(lib, Dart_NewString("DoesNotExist"));
4640 EXPECT(Dart_IsNull(var)); 4640 EXPECT(Dart_IsNull(var));
4641 4641
(...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after
6522 EXPECT(Dart_IsString(str)); 6522 EXPECT(Dart_IsString(str));
6523 len = -1; 6523 len = -1;
6524 EXPECT_VALID(Dart_StringLength(str, &len)); 6524 EXPECT_VALID(Dart_StringLength(str, &len));
6525 EXPECT_EQ(0, len); 6525 EXPECT_EQ(0, len);
6526 } 6526 }
6527 6527
6528 6528
6529 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 6529 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
6530 6530
6531 } // namespace dart 6531 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/regexp_patch.dart ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698