Mercurial > malikania
comparison tests/libclient/js-size/main.cpp @ 27:0a1adf7dcca0
Common: update libjs and adapt code
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 12 Apr 2016 13:53:11 +0200 |
parents | fb7c2c096101 |
children | a1e80d991968 |
comparison
equal
deleted
inserted
replaced
26:56cc058200b5 | 27:0a1adf7dcca0 |
---|---|
48 "w = s.width;" | 48 "w = s.width;" |
49 "h = s.height;" | 49 "h = s.height;" |
50 ); | 50 ); |
51 | 51 |
52 if (ret != 0) { | 52 if (ret != 0) { |
53 throw duk::error(m_ctx, -1); | 53 throw duk::exception(m_ctx, -1); |
54 } | 54 } |
55 | 55 |
56 ASSERT_EQ(0, duk::getGlobal<int>(m_ctx, "w")); | 56 ASSERT_EQ(0, duk::getGlobal<int>(m_ctx, "w")); |
57 ASSERT_EQ(0, duk::getGlobal<int>(m_ctx, "h")); | 57 ASSERT_EQ(0, duk::getGlobal<int>(m_ctx, "h")); |
58 } catch (const std::exception &ex) { | 58 } catch (const std::exception &ex) { |
68 "w = s.width;" | 68 "w = s.width;" |
69 "h = s.height;" | 69 "h = s.height;" |
70 ); | 70 ); |
71 | 71 |
72 if (ret != 0) { | 72 if (ret != 0) { |
73 throw duk::error(m_ctx, -1); | 73 throw duk::exception(m_ctx, -1); |
74 } | 74 } |
75 | 75 |
76 ASSERT_EQ(100, duk::getGlobal<int>(m_ctx, "w")); | 76 ASSERT_EQ(100, duk::getGlobal<int>(m_ctx, "w")); |
77 ASSERT_EQ(200, duk::getGlobal<int>(m_ctx, "h")); | 77 ASSERT_EQ(200, duk::getGlobal<int>(m_ctx, "h")); |
78 } catch (const std::exception &ex) { | 78 } catch (const std::exception &ex) { |
88 "w = s.width;" | 88 "w = s.width;" |
89 "h = s.height;" | 89 "h = s.height;" |
90 ); | 90 ); |
91 | 91 |
92 if (ret != 0) { | 92 if (ret != 0) { |
93 throw duk::error(m_ctx, -1); | 93 throw duk::exception(m_ctx, -1); |
94 } | 94 } |
95 | 95 |
96 ASSERT_EQ(100, duk::getGlobal<int>(m_ctx, "w")); | 96 ASSERT_EQ(100, duk::getGlobal<int>(m_ctx, "w")); |
97 ASSERT_EQ(200, duk::getGlobal<int>(m_ctx, "h")); | 97 ASSERT_EQ(200, duk::getGlobal<int>(m_ctx, "h")); |
98 } catch (const std::exception &ex) { | 98 } catch (const std::exception &ex) { |
108 "w = s.width;" | 108 "w = s.width;" |
109 "h = s.height;" | 109 "h = s.height;" |
110 ); | 110 ); |
111 | 111 |
112 if (ret != 0) { | 112 if (ret != 0) { |
113 throw duk::error(m_ctx, -1); | 113 throw duk::exception(m_ctx, -1); |
114 } | 114 } |
115 | 115 |
116 ASSERT_EQ(100, duk::getGlobal<int>(m_ctx, "w")); | 116 ASSERT_EQ(100, duk::getGlobal<int>(m_ctx, "w")); |
117 ASSERT_EQ(200, duk::getGlobal<int>(m_ctx, "h")); | 117 ASSERT_EQ(200, duk::getGlobal<int>(m_ctx, "h")); |
118 } catch (const std::exception &ex) { | 118 } catch (const std::exception &ex) { |
136 " correct = (e instanceof TypeError);" | 136 " correct = (e instanceof TypeError);" |
137 "}" | 137 "}" |
138 ); | 138 ); |
139 | 139 |
140 if (ret != 0) { | 140 if (ret != 0) { |
141 throw duk::error(m_ctx, -1); | 141 throw duk::exception(m_ctx, -1); |
142 } | 142 } |
143 | 143 |
144 ASSERT_EQ("TypeError", duk::getGlobal<std::string>(m_ctx, "name")); | 144 ASSERT_EQ("TypeError", duk::getGlobal<std::string>(m_ctx, "name")); |
145 ASSERT_TRUE(duk::getGlobal<bool>(m_ctx, "correct")); | 145 ASSERT_TRUE(duk::getGlobal<bool>(m_ctx, "correct")); |
146 } catch (const std::exception &ex) { | 146 } catch (const std::exception &ex) { |
159 " correct = (e instanceof RangeError);" | 159 " correct = (e instanceof RangeError);" |
160 "}" | 160 "}" |
161 ); | 161 ); |
162 | 162 |
163 if (ret != 0) { | 163 if (ret != 0) { |
164 throw duk::error(m_ctx, -1); | 164 throw duk::exception(m_ctx, -1); |
165 } | 165 } |
166 | 166 |
167 ASSERT_EQ("RangeError", duk::getGlobal<std::string>(m_ctx, "name")); | 167 ASSERT_EQ("RangeError", duk::getGlobal<std::string>(m_ctx, "name")); |
168 ASSERT_TRUE(duk::getGlobal<bool>(m_ctx, "correct")); | 168 ASSERT_TRUE(duk::getGlobal<bool>(m_ctx, "correct")); |
169 } catch (const std::exception &ex) { | 169 } catch (const std::exception &ex) { |
182 " correct = (e instanceof RangeError);" | 182 " correct = (e instanceof RangeError);" |
183 "}" | 183 "}" |
184 ); | 184 ); |
185 | 185 |
186 if (ret != 0) { | 186 if (ret != 0) { |
187 throw duk::error(m_ctx, -1); | 187 throw duk::exception(m_ctx, -1); |
188 } | 188 } |
189 | 189 |
190 ASSERT_EQ("RangeError", duk::getGlobal<std::string>(m_ctx, "name")); | 190 ASSERT_EQ("RangeError", duk::getGlobal<std::string>(m_ctx, "name")); |
191 ASSERT_TRUE(duk::getGlobal<bool>(m_ctx, "correct")); | 191 ASSERT_TRUE(duk::getGlobal<bool>(m_ctx, "correct")); |
192 } catch (const std::exception &ex) { | 192 } catch (const std::exception &ex) { |
205 " correct = (e instanceof RangeError);" | 205 " correct = (e instanceof RangeError);" |
206 "}" | 206 "}" |
207 ); | 207 ); |
208 | 208 |
209 if (ret != 0) { | 209 if (ret != 0) { |
210 throw duk::error(m_ctx, -1); | 210 throw duk::exception(m_ctx, -1); |
211 } | 211 } |
212 | 212 |
213 ASSERT_EQ("RangeError", duk::getGlobal<std::string>(m_ctx, "name")); | 213 ASSERT_EQ("RangeError", duk::getGlobal<std::string>(m_ctx, "name")); |
214 ASSERT_TRUE(duk::getGlobal<bool>(m_ctx, "correct")); | 214 ASSERT_TRUE(duk::getGlobal<bool>(m_ctx, "correct")); |
215 } catch (const std::exception &ex) { | 215 } catch (const std::exception &ex) { |
228 " correct = (e instanceof RangeError);" | 228 " correct = (e instanceof RangeError);" |
229 "}" | 229 "}" |
230 ); | 230 ); |
231 | 231 |
232 if (ret != 0) { | 232 if (ret != 0) { |
233 throw duk::error(m_ctx, -1); | 233 throw duk::exception(m_ctx, -1); |
234 } | 234 } |
235 | 235 |
236 ASSERT_EQ("RangeError", duk::getGlobal<std::string>(m_ctx, "name")); | 236 ASSERT_EQ("RangeError", duk::getGlobal<std::string>(m_ctx, "name")); |
237 ASSERT_TRUE(duk::getGlobal<bool>(m_ctx, "correct")); | 237 ASSERT_TRUE(duk::getGlobal<bool>(m_ctx, "correct")); |
238 } catch (const std::exception &ex) { | 238 } catch (const std::exception &ex) { |
258 }, 1}); | 258 }, 1}); |
259 | 259 |
260 auto ret = duk::pevalString(m_ctx, "build({ width: 100, height: 200 });"); | 260 auto ret = duk::pevalString(m_ctx, "build({ width: 100, height: 200 });"); |
261 | 261 |
262 if (ret != 0) { | 262 if (ret != 0) { |
263 throw duk::error(m_ctx, -1); | 263 throw duk::exception(m_ctx, -1); |
264 } | 264 } |
265 | 265 |
266 ASSERT_EQ(100, duk::getGlobal<int>(m_ctx, "w")); | 266 ASSERT_EQ(100, duk::getGlobal<int>(m_ctx, "w")); |
267 ASSERT_EQ(200, duk::getGlobal<int>(m_ctx, "h")); | 267 ASSERT_EQ(200, duk::getGlobal<int>(m_ctx, "h")); |
268 } catch (const std::exception &ex) { | 268 } catch (const std::exception &ex) { |
287 " correct = (e instanceof Error);" | 287 " correct = (e instanceof Error);" |
288 "}" | 288 "}" |
289 ); | 289 ); |
290 | 290 |
291 if (ret != 0) { | 291 if (ret != 0) { |
292 throw duk::error(m_ctx, -1); | 292 throw duk::exception(m_ctx, -1); |
293 } | 293 } |
294 | 294 |
295 ASSERT_EQ("Error", duk::getGlobal<std::string>(m_ctx, "name")); | 295 ASSERT_EQ("Error", duk::getGlobal<std::string>(m_ctx, "name")); |
296 ASSERT_TRUE(duk::getGlobal<bool>(m_ctx, "correct")); | 296 ASSERT_TRUE(duk::getGlobal<bool>(m_ctx, "correct")); |
297 } catch (const std::exception &ex) { | 297 } catch (const std::exception &ex) { |
317 }, 1}); | 317 }, 1}); |
318 | 318 |
319 auto ret = duk::pevalString(m_ctx, "build({});"); | 319 auto ret = duk::pevalString(m_ctx, "build({});"); |
320 | 320 |
321 if (ret != 0) { | 321 if (ret != 0) { |
322 throw duk::error(m_ctx, -1); | 322 throw duk::exception(m_ctx, -1); |
323 } | 323 } |
324 | 324 |
325 ASSERT_EQ(0, duk::getGlobal<int>(m_ctx, "r")); | 325 ASSERT_EQ(0, duk::getGlobal<int>(m_ctx, "r")); |
326 ASSERT_EQ(0, duk::getGlobal<int>(m_ctx, "g")); | 326 ASSERT_EQ(0, duk::getGlobal<int>(m_ctx, "g")); |
327 } catch (const std::exception &ex) { | 327 } catch (const std::exception &ex) { |