OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2907 v8::Local<String> name = v8_str("my-symbol"); | 2907 v8::Local<String> name = v8_str("my-symbol"); |
2908 v8::Local<v8::Symbol> glob = v8::Symbol::For(isolate, name); | 2908 v8::Local<v8::Symbol> glob = v8::Symbol::For(isolate, name); |
2909 v8::Local<v8::Symbol> glob2 = v8::Symbol::For(isolate, name); | 2909 v8::Local<v8::Symbol> glob2 = v8::Symbol::For(isolate, name); |
2910 CHECK(glob2->SameValue(glob)); | 2910 CHECK(glob2->SameValue(glob)); |
2911 | 2911 |
2912 v8::Local<v8::Symbol> glob_api = v8::Symbol::ForApi(isolate, name); | 2912 v8::Local<v8::Symbol> glob_api = v8::Symbol::ForApi(isolate, name); |
2913 v8::Local<v8::Symbol> glob_api2 = v8::Symbol::ForApi(isolate, name); | 2913 v8::Local<v8::Symbol> glob_api2 = v8::Symbol::ForApi(isolate, name); |
2914 CHECK(glob_api2->SameValue(glob_api)); | 2914 CHECK(glob_api2->SameValue(glob_api)); |
2915 CHECK(!glob_api->SameValue(glob)); | 2915 CHECK(!glob_api->SameValue(glob)); |
2916 | 2916 |
| 2917 v8::Local<String> iterator_name = v8_str("Symbol.iterator"); |
| 2918 v8::Local<v8::Symbol> iterator = |
| 2919 v8::Symbol::ForInternal(isolate, iterator_name); |
| 2920 |
2917 v8::Local<v8::Symbol> sym = v8::Symbol::New(isolate, name); | 2921 v8::Local<v8::Symbol> sym = v8::Symbol::New(isolate, name); |
2918 CHECK(!sym->SameValue(glob)); | 2922 CHECK(!sym->SameValue(glob)); |
2919 | 2923 |
2920 CompileRun("var sym2 = Symbol.for('my-symbol')"); | 2924 CompileRun("var sym2 = Symbol.for('my-symbol')"); |
2921 v8::Local<Value> sym2 = env->Global()->Get(v8_str("sym2")); | 2925 v8::Local<Value> sym2 = env->Global()->Get(v8_str("sym2")); |
2922 CHECK(sym2->SameValue(glob)); | 2926 CHECK(sym2->SameValue(glob)); |
2923 CHECK(!sym2->SameValue(glob_api)); | 2927 CHECK(!sym2->SameValue(glob_api)); |
| 2928 |
| 2929 CompileRun("var sym3 = Symbol.iterator"); |
| 2930 v8::Local<Value> sym3 = env->Global()->Get(v8_str("sym3")); |
| 2931 CHECK(!sym3.IsEmpty()); |
| 2932 CHECK(sym3->SameValue(iterator)); |
2924 } | 2933 } |
2925 | 2934 |
2926 | 2935 |
2927 THREADED_TEST(GlobalPrivates) { | 2936 THREADED_TEST(GlobalPrivates) { |
2928 LocalContext env; | 2937 LocalContext env; |
2929 v8::Isolate* isolate = env->GetIsolate(); | 2938 v8::Isolate* isolate = env->GetIsolate(); |
2930 v8::HandleScope scope(isolate); | 2939 v8::HandleScope scope(isolate); |
2931 | 2940 |
2932 v8::Local<String> name = v8_str("my-private"); | 2941 v8::Local<String> name = v8_str("my-private"); |
2933 v8::Local<v8::Private> glob = v8::Private::ForApi(isolate, name); | 2942 v8::Local<v8::Private> glob = v8::Private::ForApi(isolate, name); |
(...skipping 19942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22876 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); | 22885 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); |
22877 Local<Function> set = | 22886 Local<Function> set = |
22878 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); | 22887 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); |
22879 Local<Function> get = | 22888 Local<Function> get = |
22880 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); | 22889 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); |
22881 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); | 22890 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); |
22882 Handle<Value> args[] = { v8_num(14) }; | 22891 Handle<Value> args[] = { v8_num(14) }; |
22883 set->Call(x, 1, args); | 22892 set->Call(x, 1, args); |
22884 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); | 22893 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); |
22885 } | 22894 } |
OLD | NEW |