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

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

Issue 10834096: Added Dart_FunctionEnclosingClassOrLibrary. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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/vm/dart_api_impl.cc ('k') | no next file » | 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 3726 matching lines...) Expand 10 before | Expand all | Expand 10 after
3737 "Function getInstanceClosureWithArgs() {\n" 3737 "Function getInstanceClosureWithArgs() {\n"
3738 " return new Foo().getInstanceClosureWithArgs();\n" 3738 " return new Foo().getInstanceClosureWithArgs();\n"
3739 "}\n" 3739 "}\n"
3740 "Function getStaticClosure() {\n" 3740 "Function getStaticClosure() {\n"
3741 " return Foo.getStaticClosure();\n" 3741 " return Foo.getStaticClosure();\n"
3742 "}\n" 3742 "}\n"
3743 "Function getStaticClosureWithArgs() {\n" 3743 "Function getStaticClosureWithArgs() {\n"
3744 " return Foo.getStaticClosureWithArgs();\n" 3744 " return Foo.getStaticClosureWithArgs();\n"
3745 "}\n"; 3745 "}\n";
3746 Dart_Handle result; 3746 Dart_Handle result;
3747 Dart_Handle owner;
3747 DARTSCOPE_NOCHECKS(Isolate::Current()); 3748 DARTSCOPE_NOCHECKS(Isolate::Current());
3748 3749
3749 // Create a test library and Load up a test script in it. 3750 // Create a test library and Load up a test script in it.
3750 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 3751 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
3752 EXPECT_VALID(lib);
3753 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("Foo"));
3754 EXPECT_VALID(cls);
3751 3755
3752 // Invoke a function which returns a closure. 3756 // Invoke a function which returns a closure.
3753 Dart_Handle retobj = Dart_Invoke(lib, Dart_NewString("getClosure"), 0, NULL); 3757 Dart_Handle retobj = Dart_Invoke(lib, Dart_NewString("getClosure"), 0, NULL);
3754 EXPECT_VALID(retobj); 3758 EXPECT_VALID(retobj);
3755 3759
3756 EXPECT(Dart_IsClosure(retobj)); 3760 EXPECT(Dart_IsClosure(retobj));
3757 EXPECT(!Dart_IsClosure(Dart_NewInteger(101))); 3761 EXPECT(!Dart_IsClosure(Dart_NewInteger(101)));
3758 3762
3759 // Retrieve the closure's function 3763 // Retrieve the closure's function
3760 result = Dart_ClosureFunction(retobj); 3764 result = Dart_ClosureFunction(retobj);
3761 EXPECT_VALID(result); 3765 EXPECT_VALID(result);
3762 EXPECT(Dart_IsFunction(result)); 3766 EXPECT(Dart_IsFunction(result));
3767 owner = Dart_FunctionEnclosingClassOrLibrary(result);
3768 EXPECT_VALID(owner);
3769 EXPECT(Dart_IdentityEquals(owner, lib));
3763 int64_t fixed_param_count = -999; 3770 int64_t fixed_param_count = -999;
3764 int64_t opt_param_count = -999; 3771 int64_t opt_param_count = -999;
3765 result = Dart_FunctionParameterCounts(result, 3772 result = Dart_FunctionParameterCounts(result,
3766 &fixed_param_count, 3773 &fixed_param_count,
3767 &opt_param_count); 3774 &opt_param_count);
3768 EXPECT_VALID(result); 3775 EXPECT_VALID(result);
3769 EXPECT_EQ(2, fixed_param_count); 3776 EXPECT_EQ(2, fixed_param_count);
3770 EXPECT_EQ(1, opt_param_count); 3777 EXPECT_EQ(1, opt_param_count);
3771 3778
3772 // Try to retrieve function from a non-closure object 3779 // Try to retrieve function from a non-closure object
3773 result = Dart_ClosureFunction(Dart_NewInteger(1)); 3780 result = Dart_ClosureFunction(Dart_NewInteger(1));
3774 EXPECT(Dart_IsError(result)); 3781 EXPECT(Dart_IsError(result));
3775 3782
3776 // Invoke a function which returns an "instance" closure. 3783 // Invoke a function which returns an "instance" closure.
3777 retobj = Dart_Invoke(lib, Dart_NewString("getInstanceClosure"), 0, NULL); 3784 retobj = Dart_Invoke(lib, Dart_NewString("getInstanceClosure"), 0, NULL);
3778 EXPECT_VALID(retobj); 3785 EXPECT_VALID(retobj);
3779 EXPECT(Dart_IsClosure(retobj)); 3786 EXPECT(Dart_IsClosure(retobj));
3780 3787
3781 // Retrieve the closure's function 3788 // Retrieve the closure's function
3782 result = Dart_ClosureFunction(retobj); 3789 result = Dart_ClosureFunction(retobj);
3783 EXPECT_VALID(result); 3790 EXPECT_VALID(result);
3784 EXPECT(Dart_IsFunction(result)); 3791 EXPECT(Dart_IsFunction(result));
3792 owner = Dart_FunctionEnclosingClassOrLibrary(result);
3793 EXPECT_VALID(owner);
3794 EXPECT(Dart_IdentityEquals(owner, cls));
3785 // -999: We want to distinguish between a non-answer and a wrong answer, and 3795 // -999: We want to distinguish between a non-answer and a wrong answer, and
3786 // -1 has been a previous wrong answer 3796 // -1 has been a previous wrong answer
3787 fixed_param_count = -999; 3797 fixed_param_count = -999;
3788 opt_param_count = -999; 3798 opt_param_count = -999;
3789 result = Dart_FunctionParameterCounts(result, 3799 result = Dart_FunctionParameterCounts(result,
3790 &fixed_param_count, 3800 &fixed_param_count,
3791 &opt_param_count); 3801 &opt_param_count);
3792 EXPECT_VALID(result); 3802 EXPECT_VALID(result);
3793 EXPECT_EQ(0, fixed_param_count); 3803 EXPECT_EQ(0, fixed_param_count);
3794 EXPECT_EQ(0, opt_param_count); 3804 EXPECT_EQ(0, opt_param_count);
3795 3805
3796 // Invoke a function which returns an "instance" closure with arguments. 3806 // Invoke a function which returns an "instance" closure with arguments.
3797 retobj = Dart_Invoke(lib, 3807 retobj = Dart_Invoke(lib,
3798 Dart_NewString("getInstanceClosureWithArgs"), 3808 Dart_NewString("getInstanceClosureWithArgs"),
3799 0, 3809 0,
3800 NULL); 3810 NULL);
3801 EXPECT_VALID(retobj); 3811 EXPECT_VALID(retobj);
3802 EXPECT(Dart_IsClosure(retobj)); 3812 EXPECT(Dart_IsClosure(retobj));
3803 3813
3804 // Retrieve the closure's function 3814 // Retrieve the closure's function
3805 result = Dart_ClosureFunction(retobj); 3815 result = Dart_ClosureFunction(retobj);
3806 EXPECT_VALID(result); 3816 EXPECT_VALID(result);
3807 EXPECT(Dart_IsFunction(result)); 3817 EXPECT(Dart_IsFunction(result));
3818 owner = Dart_FunctionEnclosingClassOrLibrary(result);
3819 EXPECT_VALID(owner);
3820 EXPECT(Dart_IdentityEquals(owner, cls));
3808 // -999: We want to distinguish between a non-answer and a wrong answer, and 3821 // -999: We want to distinguish between a non-answer and a wrong answer, and
3809 // -1 has been a previous wrong answer 3822 // -1 has been a previous wrong answer
3810 fixed_param_count = -999; 3823 fixed_param_count = -999;
3811 opt_param_count = -999; 3824 opt_param_count = -999;
3812 result = Dart_FunctionParameterCounts(result, 3825 result = Dart_FunctionParameterCounts(result,
3813 &fixed_param_count, 3826 &fixed_param_count,
3814 &opt_param_count); 3827 &opt_param_count);
3815 EXPECT_VALID(result); 3828 EXPECT_VALID(result);
3816 EXPECT_EQ(2, fixed_param_count); 3829 EXPECT_EQ(2, fixed_param_count);
3817 EXPECT_EQ(1, opt_param_count); 3830 EXPECT_EQ(1, opt_param_count);
3818 3831
3819 // Invoke a function which returns a "static" closure. 3832 // Invoke a function which returns a "static" closure.
3820 retobj = Dart_Invoke(lib, Dart_NewString("getStaticClosure"), 0, NULL); 3833 retobj = Dart_Invoke(lib, Dart_NewString("getStaticClosure"), 0, NULL);
3821 EXPECT_VALID(retobj); 3834 EXPECT_VALID(retobj);
3822 EXPECT(Dart_IsClosure(retobj)); 3835 EXPECT(Dart_IsClosure(retobj));
3823 3836
3824 // Retrieve the closure's function 3837 // Retrieve the closure's function
3825 result = Dart_ClosureFunction(retobj); 3838 result = Dart_ClosureFunction(retobj);
3826 EXPECT_VALID(result); 3839 EXPECT_VALID(result);
3827 EXPECT(Dart_IsFunction(result)); 3840 EXPECT(Dart_IsFunction(result));
3841 owner = Dart_FunctionEnclosingClassOrLibrary(result);
3842 EXPECT_VALID(owner);
3843 EXPECT(Dart_IdentityEquals(owner, cls));
3828 // -999: We want to distinguish between a non-answer and a wrong answer, and 3844 // -999: We want to distinguish between a non-answer and a wrong answer, and
3829 // -1 has been a previous wrong answer 3845 // -1 has been a previous wrong answer
3830 fixed_param_count = -999; 3846 fixed_param_count = -999;
3831 opt_param_count = -999; 3847 opt_param_count = -999;
3832 result = Dart_FunctionParameterCounts(result, 3848 result = Dart_FunctionParameterCounts(result,
3833 &fixed_param_count, 3849 &fixed_param_count,
3834 &opt_param_count); 3850 &opt_param_count);
3835 EXPECT_VALID(result); 3851 EXPECT_VALID(result);
3836 EXPECT_EQ(0, fixed_param_count); 3852 EXPECT_EQ(0, fixed_param_count);
3837 EXPECT_EQ(0, opt_param_count); 3853 EXPECT_EQ(0, opt_param_count);
3838 3854
3839 3855
3840 // Invoke a function which returns a "static" closure with arguments. 3856 // Invoke a function which returns a "static" closure with arguments.
3841 retobj = Dart_Invoke(lib, 3857 retobj = Dart_Invoke(lib,
3842 Dart_NewString("getStaticClosureWithArgs"), 3858 Dart_NewString("getStaticClosureWithArgs"),
3843 0, 3859 0,
3844 NULL); 3860 NULL);
3845 EXPECT_VALID(retobj); 3861 EXPECT_VALID(retobj);
3846 EXPECT(Dart_IsClosure(retobj)); 3862 EXPECT(Dart_IsClosure(retobj));
3847 3863
3848 // Retrieve the closure's function 3864 // Retrieve the closure's function
3849 result = Dart_ClosureFunction(retobj); 3865 result = Dart_ClosureFunction(retobj);
3850 EXPECT_VALID(result); 3866 EXPECT_VALID(result);
3851 EXPECT(Dart_IsFunction(result)); 3867 EXPECT(Dart_IsFunction(result));
3868 owner = Dart_FunctionEnclosingClassOrLibrary(result);
3869 EXPECT_VALID(owner);
3870 EXPECT(Dart_IdentityEquals(owner, cls));
3852 // -999: We want to distinguish between a non-answer and a wrong answer, and 3871 // -999: We want to distinguish between a non-answer and a wrong answer, and
3853 // -1 has been a previous wrong answer 3872 // -1 has been a previous wrong answer
3854 fixed_param_count = -999; 3873 fixed_param_count = -999;
3855 opt_param_count = -999; 3874 opt_param_count = -999;
3856 result = Dart_FunctionParameterCounts(result, 3875 result = Dart_FunctionParameterCounts(result,
3857 &fixed_param_count, 3876 &fixed_param_count,
3858 &opt_param_count); 3877 &opt_param_count);
3859 EXPECT_VALID(result); 3878 EXPECT_VALID(result);
3860 EXPECT_EQ(2, fixed_param_count); 3879 EXPECT_EQ(2, fixed_param_count);
3861 EXPECT_EQ(1, opt_param_count); 3880 EXPECT_EQ(1, opt_param_count);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
4168 Dart_Handle private_cls = Dart_GetClass(lib, Dart_NewString("_PrivateClass")); 4187 Dart_Handle private_cls = Dart_GetClass(lib, Dart_NewString("_PrivateClass"));
4169 EXPECT_VALID(private_cls); 4188 EXPECT_VALID(private_cls);
4170 TextBuffer buffer(128); 4189 TextBuffer buffer(128);
4171 4190
4172 // Lookup a top-level function. 4191 // Lookup a top-level function.
4173 Dart_Handle func = Dart_LookupFunction(lib, Dart_NewString("a")); 4192 Dart_Handle func = Dart_LookupFunction(lib, Dart_NewString("a"));
4174 EXPECT_VALID(func); 4193 EXPECT_VALID(func);
4175 EXPECT(Dart_IsFunction(func)); 4194 EXPECT(Dart_IsFunction(func));
4176 BuildFunctionDescription(&buffer, func); 4195 BuildFunctionDescription(&buffer, func);
4177 EXPECT_STREQ("a 0 0 static", buffer.buf()); 4196 EXPECT_STREQ("a 0 0 static", buffer.buf());
4197 EXPECT(Dart_IsLibrary(Dart_FunctionEnclosingClassOrLibrary(func)));
4198 Dart_Handle owner = Dart_FunctionEnclosingClassOrLibrary(func);
4199 EXPECT_VALID(owner);
4200 EXPECT(Dart_IdentityEquals(owner, lib));
4178 4201
4179 // Lookup a private top-level function. 4202 // Lookup a private top-level function.
4180 func = Dart_LookupFunction(lib, Dart_NewString("_b")); 4203 func = Dart_LookupFunction(lib, Dart_NewString("_b"));
4181 EXPECT_VALID(func); 4204 EXPECT_VALID(func);
4182 EXPECT(Dart_IsFunction(func)); 4205 EXPECT(Dart_IsFunction(func));
4183 BuildFunctionDescription(&buffer, func); 4206 BuildFunctionDescription(&buffer, func);
4184 EXPECT_STREQ("_b 0 0 static", buffer.buf()); 4207 EXPECT_STREQ("_b 0 0 static", buffer.buf());
4208 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4209 EXPECT_VALID(owner);
4210 EXPECT(Dart_IdentityEquals(owner, lib));
4185 4211
4186 // Lookup a top-level getter. 4212 // Lookup a top-level getter.
4187 func = Dart_LookupFunction(lib, Dart_NewString("c")); 4213 func = Dart_LookupFunction(lib, Dart_NewString("c"));
4188 EXPECT_VALID(func); 4214 EXPECT_VALID(func);
4189 EXPECT(Dart_IsFunction(func)); 4215 EXPECT(Dart_IsFunction(func));
4190 BuildFunctionDescription(&buffer, func); 4216 BuildFunctionDescription(&buffer, func);
4191 EXPECT_STREQ("c 0 0 static getter", buffer.buf()); 4217 EXPECT_STREQ("c 0 0 static getter", buffer.buf());
4218 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4219 EXPECT_VALID(owner);
4220 EXPECT(Dart_IdentityEquals(owner, lib));
4192 4221
4193 // Lookup a top-level setter. 4222 // Lookup a top-level setter.
4194 func = Dart_LookupFunction(lib, Dart_NewString("d=")); 4223 func = Dart_LookupFunction(lib, Dart_NewString("d="));
4195 EXPECT_VALID(func); 4224 EXPECT_VALID(func);
4196 EXPECT(Dart_IsFunction(func)); 4225 EXPECT(Dart_IsFunction(func));
4197 BuildFunctionDescription(&buffer, func); 4226 BuildFunctionDescription(&buffer, func);
4198 EXPECT_STREQ("d= 1 0 static setter", buffer.buf()); 4227 EXPECT_STREQ("d= 1 0 static setter", buffer.buf());
4228 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4229 EXPECT_VALID(owner);
4230 EXPECT(Dart_IdentityEquals(owner, lib));
4199 4231
4200 // Lookup a private top-level getter. 4232 // Lookup a private top-level getter.
4201 func = Dart_LookupFunction(lib, Dart_NewString("_e")); 4233 func = Dart_LookupFunction(lib, Dart_NewString("_e"));
4202 EXPECT_VALID(func); 4234 EXPECT_VALID(func);
4203 EXPECT(Dart_IsFunction(func)); 4235 EXPECT(Dart_IsFunction(func));
4204 BuildFunctionDescription(&buffer, func); 4236 BuildFunctionDescription(&buffer, func);
4205 EXPECT_STREQ("_e 0 0 static getter", buffer.buf()); 4237 EXPECT_STREQ("_e 0 0 static getter", buffer.buf());
4238 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4239 EXPECT_VALID(owner);
4240 EXPECT(Dart_IdentityEquals(owner, lib));
4206 4241
4207 // Lookup a private top-level setter. 4242 // Lookup a private top-level setter.
4208 func = Dart_LookupFunction(lib, Dart_NewString("_f=")); 4243 func = Dart_LookupFunction(lib, Dart_NewString("_f="));
4209 EXPECT_VALID(func); 4244 EXPECT_VALID(func);
4210 EXPECT(Dart_IsFunction(func)); 4245 EXPECT(Dart_IsFunction(func));
4211 BuildFunctionDescription(&buffer, func); 4246 BuildFunctionDescription(&buffer, func);
4212 EXPECT_STREQ("_f= 1 0 static setter", buffer.buf()); 4247 EXPECT_STREQ("_f= 1 0 static setter", buffer.buf());
4248 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4249 EXPECT_VALID(owner);
4250 EXPECT(Dart_IdentityEquals(owner, lib));
4213 4251
4214 // Lookup an unnamed constructor 4252 // Lookup an unnamed constructor
4215 func = Dart_LookupFunction(cls, Dart_NewString("MyClass")); 4253 func = Dart_LookupFunction(cls, Dart_NewString("MyClass"));
4216 EXPECT_VALID(func); 4254 EXPECT_VALID(func);
4217 EXPECT(Dart_IsFunction(func)); 4255 EXPECT(Dart_IsFunction(func));
4218 BuildFunctionDescription(&buffer, func); 4256 BuildFunctionDescription(&buffer, func);
4219 EXPECT_STREQ("MyClass 0 0 constructor", buffer.buf()); 4257 EXPECT_STREQ("MyClass 0 0 constructor", buffer.buf());
4258 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4259 EXPECT_VALID(owner);
4260 EXPECT(Dart_IdentityEquals(owner, cls));
4220 4261
4221 // Lookup a named constructor 4262 // Lookup a named constructor
4222 func = Dart_LookupFunction(cls, Dart_NewString("MyClass.named")); 4263 func = Dart_LookupFunction(cls, Dart_NewString("MyClass.named"));
4223 EXPECT_VALID(func); 4264 EXPECT_VALID(func);
4224 EXPECT(Dart_IsFunction(func)); 4265 EXPECT(Dart_IsFunction(func));
4225 BuildFunctionDescription(&buffer, func); 4266 BuildFunctionDescription(&buffer, func);
4226 EXPECT_STREQ("MyClass.named 0 0 constructor", buffer.buf()); 4267 EXPECT_STREQ("MyClass.named 0 0 constructor", buffer.buf());
4268 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4269 EXPECT_VALID(owner);
4270 EXPECT(Dart_IdentityEquals(owner, cls));
4227 4271
4228 // Lookup an private unnamed constructor 4272 // Lookup an private unnamed constructor
4229 func = Dart_LookupFunction(private_cls, Dart_NewString("_PrivateClass")); 4273 func = Dart_LookupFunction(private_cls, Dart_NewString("_PrivateClass"));
4230 EXPECT_VALID(func); 4274 EXPECT_VALID(func);
4231 EXPECT(Dart_IsFunction(func)); 4275 EXPECT(Dart_IsFunction(func));
4232 BuildFunctionDescription(&buffer, func); 4276 BuildFunctionDescription(&buffer, func);
4233 EXPECT_STREQ("_PrivateClass 0 0 constructor", buffer.buf()); 4277 EXPECT_STREQ("_PrivateClass 0 0 constructor", buffer.buf());
4278 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4279 EXPECT_VALID(owner);
4280 EXPECT(Dart_IdentityEquals(owner, private_cls));
4234 4281
4235 // Lookup a private named constructor 4282 // Lookup a private named constructor
4236 func = Dart_LookupFunction(private_cls, 4283 func = Dart_LookupFunction(private_cls,
4237 Dart_NewString("_PrivateClass.named")); 4284 Dart_NewString("_PrivateClass.named"));
4238 EXPECT_VALID(func); 4285 EXPECT_VALID(func);
4239 EXPECT(Dart_IsFunction(func)); 4286 EXPECT(Dart_IsFunction(func));
4240 BuildFunctionDescription(&buffer, func); 4287 BuildFunctionDescription(&buffer, func);
4241 EXPECT_STREQ("_PrivateClass.named 0 0 constructor", buffer.buf()); 4288 EXPECT_STREQ("_PrivateClass.named 0 0 constructor", buffer.buf());
4289 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4290 EXPECT_VALID(owner);
4291 EXPECT(Dart_IdentityEquals(owner, private_cls));
4242 4292
4243 // Lookup a method. 4293 // Lookup a method.
4244 func = Dart_LookupFunction(cls, Dart_NewString("a")); 4294 func = Dart_LookupFunction(cls, Dart_NewString("a"));
4245 EXPECT_VALID(func); 4295 EXPECT_VALID(func);
4246 EXPECT(Dart_IsFunction(func)); 4296 EXPECT(Dart_IsFunction(func));
4247 BuildFunctionDescription(&buffer, func); 4297 BuildFunctionDescription(&buffer, func);
4248 EXPECT_STREQ("a 0 0", buffer.buf()); 4298 EXPECT_STREQ("a 0 0", buffer.buf());
4299 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4300 EXPECT_VALID(owner);
4301 EXPECT(Dart_IdentityEquals(owner, cls));
4249 4302
4250 // Lookup a private method. 4303 // Lookup a private method.
4251 func = Dart_LookupFunction(cls, Dart_NewString("_b")); 4304 func = Dart_LookupFunction(cls, Dart_NewString("_b"));
4252 EXPECT_VALID(func); 4305 EXPECT_VALID(func);
4253 EXPECT(Dart_IsFunction(func)); 4306 EXPECT(Dart_IsFunction(func));
4254 BuildFunctionDescription(&buffer, func); 4307 BuildFunctionDescription(&buffer, func);
4255 EXPECT_STREQ("_b 0 0", buffer.buf()); 4308 EXPECT_STREQ("_b 0 0", buffer.buf());
4309 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4310 EXPECT_VALID(owner);
4311 EXPECT(Dart_IdentityEquals(owner, cls));
4256 4312
4257 // Lookup a instance getter. 4313 // Lookup a instance getter.
4258 func = Dart_LookupFunction(cls, Dart_NewString("c")); 4314 func = Dart_LookupFunction(cls, Dart_NewString("c"));
4259 EXPECT_VALID(func); 4315 EXPECT_VALID(func);
4260 EXPECT(Dart_IsFunction(func)); 4316 EXPECT(Dart_IsFunction(func));
4261 BuildFunctionDescription(&buffer, func); 4317 BuildFunctionDescription(&buffer, func);
4262 EXPECT_STREQ("c 0 0 getter", buffer.buf()); 4318 EXPECT_STREQ("c 0 0 getter", buffer.buf());
4319 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4320 EXPECT_VALID(owner);
4321 EXPECT(Dart_IdentityEquals(owner, cls));
4263 4322
4264 // Lookup a instance setter. 4323 // Lookup a instance setter.
4265 func = Dart_LookupFunction(cls, Dart_NewString("d=")); 4324 func = Dart_LookupFunction(cls, Dart_NewString("d="));
4266 EXPECT_VALID(func); 4325 EXPECT_VALID(func);
4267 EXPECT(Dart_IsFunction(func)); 4326 EXPECT(Dart_IsFunction(func));
4268 BuildFunctionDescription(&buffer, func); 4327 BuildFunctionDescription(&buffer, func);
4269 EXPECT_STREQ("d= 1 0 setter", buffer.buf()); 4328 EXPECT_STREQ("d= 1 0 setter", buffer.buf());
4329 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4330 EXPECT_VALID(owner);
4331 EXPECT(Dart_IdentityEquals(owner, cls));
4270 4332
4271 // Lookup a private instance getter. 4333 // Lookup a private instance getter.
4272 func = Dart_LookupFunction(cls, Dart_NewString("_e")); 4334 func = Dart_LookupFunction(cls, Dart_NewString("_e"));
4273 EXPECT_VALID(func); 4335 EXPECT_VALID(func);
4274 EXPECT(Dart_IsFunction(func)); 4336 EXPECT(Dart_IsFunction(func));
4275 BuildFunctionDescription(&buffer, func); 4337 BuildFunctionDescription(&buffer, func);
4276 EXPECT_STREQ("_e 0 0 getter", buffer.buf()); 4338 EXPECT_STREQ("_e 0 0 getter", buffer.buf());
4339 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4340 EXPECT_VALID(owner);
4341 EXPECT(Dart_IdentityEquals(owner, cls));
4277 4342
4278 // Lookup a private instance setter. 4343 // Lookup a private instance setter.
4279 func = Dart_LookupFunction(cls, Dart_NewString("_f=")); 4344 func = Dart_LookupFunction(cls, Dart_NewString("_f="));
4280 EXPECT_VALID(func); 4345 EXPECT_VALID(func);
4281 EXPECT(Dart_IsFunction(func)); 4346 EXPECT(Dart_IsFunction(func));
4282 BuildFunctionDescription(&buffer, func); 4347 BuildFunctionDescription(&buffer, func);
4283 EXPECT_STREQ("_f= 1 0 setter", buffer.buf()); 4348 EXPECT_STREQ("_f= 1 0 setter", buffer.buf());
4349 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4350 EXPECT_VALID(owner);
4351 EXPECT(Dart_IdentityEquals(owner, cls));
4284 4352
4285 // Lookup a static method. 4353 // Lookup a static method.
4286 func = Dart_LookupFunction(cls, Dart_NewString("g")); 4354 func = Dart_LookupFunction(cls, Dart_NewString("g"));
4287 EXPECT_VALID(func); 4355 EXPECT_VALID(func);
4288 EXPECT(Dart_IsFunction(func)); 4356 EXPECT(Dart_IsFunction(func));
4289 BuildFunctionDescription(&buffer, func); 4357 BuildFunctionDescription(&buffer, func);
4290 EXPECT_STREQ("g 0 0 static", buffer.buf()); 4358 EXPECT_STREQ("g 0 0 static", buffer.buf());
4359 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4360 EXPECT_VALID(owner);
4361 EXPECT(Dart_IdentityEquals(owner, cls));
4291 4362
4292 // Lookup a private static method. 4363 // Lookup a private static method.
4293 func = Dart_LookupFunction(cls, Dart_NewString("_h")); 4364 func = Dart_LookupFunction(cls, Dart_NewString("_h"));
4294 EXPECT_VALID(func); 4365 EXPECT_VALID(func);
4295 EXPECT(Dart_IsFunction(func)); 4366 EXPECT(Dart_IsFunction(func));
4296 BuildFunctionDescription(&buffer, func); 4367 BuildFunctionDescription(&buffer, func);
4297 EXPECT_STREQ("_h 0 0 static", buffer.buf()); 4368 EXPECT_STREQ("_h 0 0 static", buffer.buf());
4369 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4370 EXPECT_VALID(owner);
4371 EXPECT(Dart_IdentityEquals(owner, cls));
4298 4372
4299 // Lookup a static getter. 4373 // Lookup a static getter.
4300 func = Dart_LookupFunction(cls, Dart_NewString("i")); 4374 func = Dart_LookupFunction(cls, Dart_NewString("i"));
4301 EXPECT_VALID(func); 4375 EXPECT_VALID(func);
4302 EXPECT(Dart_IsFunction(func)); 4376 EXPECT(Dart_IsFunction(func));
4303 BuildFunctionDescription(&buffer, func); 4377 BuildFunctionDescription(&buffer, func);
4304 EXPECT_STREQ("i 0 0 static getter", buffer.buf()); 4378 EXPECT_STREQ("i 0 0 static getter", buffer.buf());
4379 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4380 EXPECT_VALID(owner);
4381 EXPECT(Dart_IdentityEquals(owner, cls));
4305 4382
4306 // Lookup a static setter. 4383 // Lookup a static setter.
4307 func = Dart_LookupFunction(cls, Dart_NewString("j=")); 4384 func = Dart_LookupFunction(cls, Dart_NewString("j="));
4308 EXPECT_VALID(func); 4385 EXPECT_VALID(func);
4309 EXPECT(Dart_IsFunction(func)); 4386 EXPECT(Dart_IsFunction(func));
4310 BuildFunctionDescription(&buffer, func); 4387 BuildFunctionDescription(&buffer, func);
4311 EXPECT_STREQ("j= 1 0 static setter", buffer.buf()); 4388 EXPECT_STREQ("j= 1 0 static setter", buffer.buf());
4389 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4390 EXPECT_VALID(owner);
4391 EXPECT(Dart_IdentityEquals(owner, cls));
4312 4392
4313 // Lookup a private static getter. 4393 // Lookup a private static getter.
4314 func = Dart_LookupFunction(cls, Dart_NewString("_k")); 4394 func = Dart_LookupFunction(cls, Dart_NewString("_k"));
4315 EXPECT_VALID(func); 4395 EXPECT_VALID(func);
4316 EXPECT(Dart_IsFunction(func)); 4396 EXPECT(Dart_IsFunction(func));
4317 BuildFunctionDescription(&buffer, func); 4397 BuildFunctionDescription(&buffer, func);
4318 EXPECT_STREQ("_k 0 0 static getter", buffer.buf()); 4398 EXPECT_STREQ("_k 0 0 static getter", buffer.buf());
4399 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4400 EXPECT_VALID(owner);
4401 EXPECT(Dart_IdentityEquals(owner, cls));
4319 4402
4320 // Lookup a private static setter. 4403 // Lookup a private static setter.
4321 func = Dart_LookupFunction(cls, Dart_NewString("_l=")); 4404 func = Dart_LookupFunction(cls, Dart_NewString("_l="));
4322 EXPECT_VALID(func); 4405 EXPECT_VALID(func);
4323 EXPECT(Dart_IsFunction(func)); 4406 EXPECT(Dart_IsFunction(func));
4324 BuildFunctionDescription(&buffer, func); 4407 BuildFunctionDescription(&buffer, func);
4325 EXPECT_STREQ("_l= 1 0 static setter", buffer.buf()); 4408 EXPECT_STREQ("_l= 1 0 static setter", buffer.buf());
4409 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4410 EXPECT_VALID(owner);
4411 EXPECT(Dart_IdentityEquals(owner, cls));
4326 4412
4327 // Lookup an abstract method. 4413 // Lookup an abstract method.
4328 func = Dart_LookupFunction(cls, Dart_NewString("m")); 4414 func = Dart_LookupFunction(cls, Dart_NewString("m"));
4329 EXPECT_VALID(func); 4415 EXPECT_VALID(func);
4330 EXPECT(Dart_IsFunction(func)); 4416 EXPECT(Dart_IsFunction(func));
4331 BuildFunctionDescription(&buffer, func); 4417 BuildFunctionDescription(&buffer, func);
4332 EXPECT_STREQ("m 0 0 abstract", buffer.buf()); 4418 EXPECT_STREQ("m 0 0 abstract", buffer.buf());
4419 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4420 EXPECT_VALID(owner);
4421 EXPECT(Dart_IdentityEquals(owner, cls));
4333 4422
4334 // Lookup a private abstract method. 4423 // Lookup a private abstract method.
4335 func = Dart_LookupFunction(cls, Dart_NewString("_n")); 4424 func = Dart_LookupFunction(cls, Dart_NewString("_n"));
4336 EXPECT_VALID(func); 4425 EXPECT_VALID(func);
4337 EXPECT(Dart_IsFunction(func)); 4426 EXPECT(Dart_IsFunction(func));
4338 BuildFunctionDescription(&buffer, func); 4427 BuildFunctionDescription(&buffer, func);
4339 EXPECT_STREQ("_n 0 0 abstract", buffer.buf()); 4428 EXPECT_STREQ("_n 0 0 abstract", buffer.buf());
4429 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4430 EXPECT_VALID(owner);
4431 EXPECT(Dart_IdentityEquals(owner, cls));
4340 4432
4341 // Lookup a abstract getter. 4433 // Lookup a abstract getter.
4342 func = Dart_LookupFunction(cls, Dart_NewString("o")); 4434 func = Dart_LookupFunction(cls, Dart_NewString("o"));
4343 EXPECT_VALID(func); 4435 EXPECT_VALID(func);
4344 EXPECT(Dart_IsFunction(func)); 4436 EXPECT(Dart_IsFunction(func));
4345 BuildFunctionDescription(&buffer, func); 4437 BuildFunctionDescription(&buffer, func);
4346 EXPECT_STREQ("o 0 0 abstract getter", buffer.buf()); 4438 EXPECT_STREQ("o 0 0 abstract getter", buffer.buf());
4439 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4440 EXPECT_VALID(owner);
4441 EXPECT(Dart_IdentityEquals(owner, cls));
4347 4442
4348 // Lookup a abstract setter. 4443 // Lookup a abstract setter.
4349 func = Dart_LookupFunction(cls, Dart_NewString("p=")); 4444 func = Dart_LookupFunction(cls, Dart_NewString("p="));
4350 EXPECT_VALID(func); 4445 EXPECT_VALID(func);
4351 EXPECT(Dart_IsFunction(func)); 4446 EXPECT(Dart_IsFunction(func));
4352 BuildFunctionDescription(&buffer, func); 4447 BuildFunctionDescription(&buffer, func);
4353 EXPECT_STREQ("p= 1 0 abstract setter", buffer.buf()); 4448 EXPECT_STREQ("p= 1 0 abstract setter", buffer.buf());
4449 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4450 EXPECT_VALID(owner);
4451 EXPECT(Dart_IdentityEquals(owner, cls));
4354 4452
4355 // Lookup a private abstract getter. 4453 // Lookup a private abstract getter.
4356 func = Dart_LookupFunction(cls, Dart_NewString("_q")); 4454 func = Dart_LookupFunction(cls, Dart_NewString("_q"));
4357 EXPECT_VALID(func); 4455 EXPECT_VALID(func);
4358 EXPECT(Dart_IsFunction(func)); 4456 EXPECT(Dart_IsFunction(func));
4359 BuildFunctionDescription(&buffer, func); 4457 BuildFunctionDescription(&buffer, func);
4360 EXPECT_STREQ("_q 0 0 abstract getter", buffer.buf()); 4458 EXPECT_STREQ("_q 0 0 abstract getter", buffer.buf());
4459 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4460 EXPECT_VALID(owner);
4461 EXPECT(Dart_IdentityEquals(owner, cls));
4361 4462
4362 // Lookup a private abstract setter. 4463 // Lookup a private abstract setter.
4363 func = Dart_LookupFunction(cls, Dart_NewString("_r=")); 4464 func = Dart_LookupFunction(cls, Dart_NewString("_r="));
4364 EXPECT_VALID(func); 4465 EXPECT_VALID(func);
4365 EXPECT(Dart_IsFunction(func)); 4466 EXPECT(Dart_IsFunction(func));
4366 BuildFunctionDescription(&buffer, func); 4467 BuildFunctionDescription(&buffer, func);
4367 EXPECT_STREQ("_r= 1 0 abstract setter", buffer.buf()); 4468 EXPECT_STREQ("_r= 1 0 abstract setter", buffer.buf());
4469 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4470 EXPECT_VALID(owner);
4471 EXPECT(Dart_IdentityEquals(owner, cls));
4368 4472
4369 // Lookup a method with fixed and optional parameters. 4473 // Lookup a method with fixed and optional parameters.
4370 func = Dart_LookupFunction(cls, Dart_NewString("s")); 4474 func = Dart_LookupFunction(cls, Dart_NewString("s"));
4371 EXPECT_VALID(func); 4475 EXPECT_VALID(func);
4372 EXPECT(Dart_IsFunction(func)); 4476 EXPECT(Dart_IsFunction(func));
4373 BuildFunctionDescription(&buffer, func); 4477 BuildFunctionDescription(&buffer, func);
4374 EXPECT_STREQ("s 1 2", buffer.buf()); 4478 EXPECT_STREQ("s 1 2", buffer.buf());
4479 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4480 EXPECT_VALID(owner);
4481 EXPECT(Dart_IdentityEquals(owner, cls));
4375 4482
4376 // Lookup a method with only optional parameters. 4483 // Lookup a method with only optional parameters.
4377 func = Dart_LookupFunction(cls, Dart_NewString("t")); 4484 func = Dart_LookupFunction(cls, Dart_NewString("t"));
4378 EXPECT_VALID(func); 4485 EXPECT_VALID(func);
4379 EXPECT(Dart_IsFunction(func)); 4486 EXPECT(Dart_IsFunction(func));
4380 BuildFunctionDescription(&buffer, func); 4487 BuildFunctionDescription(&buffer, func);
4381 EXPECT_STREQ("t 0 3", buffer.buf()); 4488 EXPECT_STREQ("t 0 3", buffer.buf());
4489 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4490 EXPECT_VALID(owner);
4491 EXPECT(Dart_IdentityEquals(owner, cls));
4382 4492
4383 // Lookup an operator 4493 // Lookup an operator
4384 func = Dart_LookupFunction(cls, Dart_NewString("==")); 4494 func = Dart_LookupFunction(cls, Dart_NewString("=="));
4385 EXPECT_VALID(func); 4495 EXPECT_VALID(func);
4386 EXPECT(Dart_IsFunction(func)); 4496 EXPECT(Dart_IsFunction(func));
4387 BuildFunctionDescription(&buffer, func); 4497 BuildFunctionDescription(&buffer, func);
4388 EXPECT_STREQ("== 1 0", buffer.buf()); 4498 EXPECT_STREQ("== 1 0", buffer.buf());
4499 owner = Dart_FunctionEnclosingClassOrLibrary(func);
4500 EXPECT_VALID(owner);
4501 EXPECT(Dart_IdentityEquals(owner, cls));
4389 4502
4390 // Lookup a function that does not exist from a library. 4503 // Lookup a function that does not exist from a library.
4391 func = Dart_LookupFunction(lib, Dart_NewString("DoesNotExist")); 4504 func = Dart_LookupFunction(lib, Dart_NewString("DoesNotExist"));
4392 EXPECT(Dart_IsNull(func)); 4505 EXPECT(Dart_IsNull(func));
4393 4506
4394 // Lookup a function that does not exist from a class. 4507 // Lookup a function that does not exist from a class.
4395 func = Dart_LookupFunction(cls, Dart_NewString("DoesNotExist")); 4508 func = Dart_LookupFunction(cls, Dart_NewString("DoesNotExist"));
4396 EXPECT(Dart_IsNull(func)); 4509 EXPECT(Dart_IsNull(func));
4397 4510
4398 // Lookup a class using an error class name. The error propagates. 4511 // Lookup a class using an error class name. The error propagates.
(...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after
6375 EXPECT_VALID(result); 6488 EXPECT_VALID(result);
6376 EXPECT(Dart_IsInteger(result)); 6489 EXPECT(Dart_IsInteger(result));
6377 int64_t value = 0; 6490 int64_t value = 0;
6378 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); 6491 EXPECT_VALID(Dart_IntegerToInt64(result, &value));
6379 EXPECT_EQ(0, value); 6492 EXPECT_EQ(0, value);
6380 } 6493 }
6381 6494
6382 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 6495 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
6383 6496
6384 } // namespace dart 6497 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698