Index: test/cctest/test-proxies.cc |
diff --git a/test/cctest/test-proxies.cc b/test/cctest/test-proxies.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..db9e30d41e38dc1f5f055e13cf5faad9ffc5f4c4 |
--- /dev/null |
+++ b/test/cctest/test-proxies.cc |
@@ -0,0 +1,33 @@ |
+// Copyright 2015 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include <stdlib.h> |
+ |
+#include "src/v8.h" |
+#include "test/cctest/cctest.h" |
+ |
+ |
+TEST(Proxy) { |
Yang
2015/12/22 14:47:55
I would have put this in test-api.cc, where all ot
Camillo Bruni
2015/12/22 14:52:24
can do, I preferred a separate file ;)
|
+ i::FLAG_harmony_proxies = true; |
+ LocalContext context; |
+ v8::Isolate* isolate = CcTest::isolate(); |
+ v8::HandleScope scope(isolate); |
+ v8::Local<v8::Object> target = CompileRun("({})").As<v8::Object>(); |
+ v8::Local<v8::Object> handler = CompileRun("({})").As<v8::Object>(); |
+ |
+ v8::Local<v8::Proxy> proxy = |
+ v8::Proxy::New(context.local(), target, handler).ToLocalChecked(); |
+ CHECK(proxy->IsProxy()); |
+ CHECK(!target->IsProxy()); |
+ CHECK(!proxy->IsRevoked()); |
+ CHECK(proxy->GetTarget()->SameValue(target)); |
+ CHECK(proxy->GetHandler()->SameValue(handler)); |
+ |
+ proxy->Revoke(); |
+ CHECK(proxy->IsProxy()); |
+ CHECK(!target->IsProxy()); |
+ CHECK(proxy->IsRevoked()); |
+ CHECK(proxy->GetTarget()->SameValue(target)); |
+ CHECK(proxy->GetHandler()->IsNull()); |
+} |