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

Side by Side Diff: Source/bindings/core/v8/V8BindingTest.cpp

Issue 967293002: [bindings] Make toFloat inline (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed stale code Created 5 years, 9 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
« no previous file with comments | « Source/bindings/core/v8/V8Binding.cpp ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "bindings/core/v8/V8Binding.h" 6 #include "bindings/core/v8/V8Binding.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ToV8.h" 9 #include "bindings/core/v8/ToV8.h"
10 #include "wtf/Vector.h" 10 #include "wtf/Vector.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 v8::Handle<v8::Array> v8Array = v8::Array::New(m_scope.isolate(), 3); 71 v8::Handle<v8::Array> v8Array = v8::Array::New(m_scope.isolate(), 3);
72 v8Array->Set(toV8(0), toV8("Vini, vidi, vici.")); 72 v8Array->Set(toV8(0), toV8("Vini, vidi, vici."));
73 v8Array->Set(toV8(1), toV8(65535)); 73 v8Array->Set(toV8(1), toV8(65535));
74 v8Array->Set(toV8(2), toV8(0.125)); 74 v8Array->Set(toV8(2), toV8(0.125));
75 75
76 NonThrowableExceptionState exceptionState; 76 NonThrowableExceptionState exceptionState;
77 Vector<v8::Local<v8::Value>> v8HandleVector = toImplArray<v8::Local<v8:: Value>>(v8Array, 0, m_scope.isolate(), exceptionState); 77 Vector<v8::Local<v8::Value>> v8HandleVector = toImplArray<v8::Local<v8:: Value>>(v8Array, 0, m_scope.isolate(), exceptionState);
78 EXPECT_EQ(3U, v8HandleVector.size()); 78 EXPECT_EQ(3U, v8HandleVector.size());
79 EXPECT_EQ("Vini, vidi, vici.", toUSVString(v8HandleVector[0], exceptionS tate)); 79 EXPECT_EQ("Vini, vidi, vici.", toUSVString(v8HandleVector[0], exceptionS tate));
80 EXPECT_EQ(65535U, toUInt32(v8HandleVector[1])); 80 EXPECT_EQ(65535U, toUInt32(v8HandleVector[1]));
81 EXPECT_EQ(0.125, toFloat(v8HandleVector[2]));
82 81
83 Vector<ScriptValue> scriptValueVector = toImplArray<ScriptValue>(v8Array , 0, m_scope.isolate(), exceptionState); 82 Vector<ScriptValue> scriptValueVector = toImplArray<ScriptValue>(v8Array , 0, m_scope.isolate(), exceptionState);
84 EXPECT_EQ(3U, scriptValueVector.size()); 83 EXPECT_EQ(3U, scriptValueVector.size());
85 String reportOnZela; 84 String reportOnZela;
86 EXPECT_TRUE(scriptValueVector[0].toString(reportOnZela)); 85 EXPECT_TRUE(scriptValueVector[0].toString(reportOnZela));
87 EXPECT_EQ("Vini, vidi, vici.", reportOnZela); 86 EXPECT_EQ("Vini, vidi, vici.", reportOnZela);
88 EXPECT_EQ(65535U, toUInt32(scriptValueVector[1].v8Value())); 87 EXPECT_EQ(65535U, toUInt32(scriptValueVector[1].v8Value()));
89 EXPECT_EQ(0.125, toFloat(scriptValueVector[2].v8Value()));
90 } 88 }
91 { 89 {
92 v8::Handle<v8::Array> v8StringArray1 = v8::Array::New(m_scope.isolate(), 2); 90 v8::Handle<v8::Array> v8StringArray1 = v8::Array::New(m_scope.isolate(), 2);
93 v8StringArray1->Set(toV8(0), toV8("foo")); 91 v8StringArray1->Set(toV8(0), toV8("foo"));
94 v8StringArray1->Set(toV8(1), toV8("bar")); 92 v8StringArray1->Set(toV8(1), toV8("bar"));
95 v8::Handle<v8::Array> v8StringArray2 = v8::Array::New(m_scope.isolate(), 3); 93 v8::Handle<v8::Array> v8StringArray2 = v8::Array::New(m_scope.isolate(), 3);
96 v8StringArray2->Set(toV8(0), toV8("x")); 94 v8StringArray2->Set(toV8(0), toV8("x"));
97 v8StringArray2->Set(toV8(1), toV8("y")); 95 v8StringArray2->Set(toV8(1), toV8("y"));
98 v8StringArray2->Set(toV8(2), toV8("z")); 96 v8StringArray2->Set(toV8(2), toV8("z"));
99 v8::Handle<v8::Array> v8StringArrayArray = v8::Array::New(m_scope.isolat e(), 2); 97 v8::Handle<v8::Array> v8StringArrayArray = v8::Array::New(m_scope.isolat e(), 2);
100 v8StringArrayArray->Set(toV8(0), v8StringArray1); 98 v8StringArrayArray->Set(toV8(0), v8StringArray1);
101 v8StringArrayArray->Set(toV8(1), v8StringArray2); 99 v8StringArrayArray->Set(toV8(1), v8StringArray2);
102 100
103 NonThrowableExceptionState exceptionState; 101 NonThrowableExceptionState exceptionState;
104 Vector<Vector<String>> stringVectorVector = toImplArray<Vector<String>>( v8StringArrayArray, 0, m_scope.isolate(), exceptionState); 102 Vector<Vector<String>> stringVectorVector = toImplArray<Vector<String>>( v8StringArrayArray, 0, m_scope.isolate(), exceptionState);
105 EXPECT_EQ(2U, stringVectorVector.size()); 103 EXPECT_EQ(2U, stringVectorVector.size());
106 EXPECT_EQ(2U, stringVectorVector[0].size()); 104 EXPECT_EQ(2U, stringVectorVector[0].size());
107 EXPECT_EQ("foo", stringVectorVector[0][0]); 105 EXPECT_EQ("foo", stringVectorVector[0][0]);
108 EXPECT_EQ("bar", stringVectorVector[0][1]); 106 EXPECT_EQ("bar", stringVectorVector[0][1]);
109 EXPECT_EQ(3U, stringVectorVector[1].size()); 107 EXPECT_EQ(3U, stringVectorVector[1].size());
110 EXPECT_EQ("x", stringVectorVector[1][0]); 108 EXPECT_EQ("x", stringVectorVector[1][0]);
111 EXPECT_EQ("y", stringVectorVector[1][1]); 109 EXPECT_EQ("y", stringVectorVector[1][1]);
112 EXPECT_EQ("z", stringVectorVector[1][2]); 110 EXPECT_EQ("z", stringVectorVector[1][2]);
113 } 111 }
114 } 112 }
115 113
116 } // namespace 114 } // namespace
117 115
118 } // namespace blink 116 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8Binding.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698