OLD | NEW |
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 "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/globals.h" | 6 #include "vm/globals.h" |
7 | 7 |
8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/code_descriptors.h" | 10 #include "vm/code_descriptors.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 while (it.MoveNext()) { | 312 while (it.MoveNext()) { |
313 if (token_positions[i] != it.TokenPos().value()) { | 313 if (token_positions[i] != it.TokenPos().value()) { |
314 OS::Print("[%" Pd "]: Expected: %" Pd " != %" Pd "\n", i, | 314 OS::Print("[%" Pd "]: Expected: %" Pd " != %" Pd "\n", i, |
315 token_positions[i], it.TokenPos().value()); | 315 token_positions[i], it.TokenPos().value()); |
316 } | 316 } |
317 EXPECT(token_positions[i] == it.TokenPos().value()); | 317 EXPECT(token_positions[i] == it.TokenPos().value()); |
318 i++; | 318 i++; |
319 } | 319 } |
320 } | 320 } |
321 | 321 |
322 | |
323 TEST_CASE(CodeSourceMap_TokenPositions) { | |
324 const intptr_t token_positions[] = { | |
325 kMinInt32, | |
326 5, | |
327 13, | |
328 13, | |
329 13, | |
330 13, | |
331 31, | |
332 23, | |
333 23, | |
334 23, | |
335 33, | |
336 33, | |
337 5, | |
338 5, | |
339 TokenPosition::kMinSourcePos, | |
340 TokenPosition::kMaxSourcePos, | |
341 }; | |
342 const intptr_t num_token_positions = | |
343 sizeof(token_positions) / sizeof(token_positions[0]); | |
344 | |
345 CodeSourceMapBuilder* builder = new CodeSourceMapBuilder(); | |
346 ASSERT(builder != NULL); | |
347 | |
348 for (intptr_t i = 0; i < num_token_positions; i++) { | |
349 builder->AddEntry(i, TokenPosition(token_positions[i])); | |
350 } | |
351 | |
352 const CodeSourceMap& code_Source_map = | |
353 CodeSourceMap::Handle(builder->Finalize()); | |
354 | |
355 ASSERT(!code_Source_map.IsNull()); | |
356 CodeSourceMap::Iterator it(code_Source_map); | |
357 | |
358 uintptr_t i = 0; | |
359 while (it.MoveNext()) { | |
360 EXPECT(it.PcOffset() == i); | |
361 if (token_positions[i] != it.TokenPos().value()) { | |
362 OS::Print("[%" Pd "]: Expected: %" Pd " != %" Pd "\n", i, | |
363 token_positions[i], it.TokenPos().value()); | |
364 } | |
365 EXPECT(token_positions[i] == it.TokenPos().value()); | |
366 i++; | |
367 } | |
368 } | |
369 | |
370 } // namespace dart | 322 } // namespace dart |
OLD | NEW |