| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 uc16* range = ranges[j]; | 590 uc16* range = ranges[j]; |
| 591 bool is_on = false; | 591 bool is_on = false; |
| 592 for (int k = 0; !is_on && (k < 2 * kRangeSize); k += 2) | 592 for (int k = 0; !is_on && (k < 2 * kRangeSize); k += 2) |
| 593 is_on = (range[k] <= p && p <= range[k + 1]); | 593 is_on = (range[k] <= p && p <= range[k + 1]); |
| 594 CHECK_EQ(is_on, outs->Get(j)); | 594 CHECK_EQ(is_on, outs->Get(j)); |
| 595 } | 595 } |
| 596 } | 596 } |
| 597 } | 597 } |
| 598 | 598 |
| 599 | 599 |
| 600 // Tests of interpreter. |
| 601 |
| 600 TEST(MacroAssembler) { | 602 TEST(MacroAssembler) { |
| 601 V8::Initialize(NULL); | 603 V8::Initialize(NULL); |
| 602 byte codes[1024]; | 604 byte codes[1024]; |
| 603 RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024)); | 605 RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024)); |
| 604 // ^f(o)o. | 606 // ^f(o)o. |
| 605 Label fail, fail2, start; | 607 Label fail, fail2, start; |
| 606 uc16 foo_chars[3]; | 608 uc16 foo_chars[3]; |
| 607 foo_chars[0] = 'f'; | 609 foo_chars[0] = 'f'; |
| 608 foo_chars[1] = 'o'; | 610 foo_chars[1] = 'o'; |
| 609 foo_chars[2] = 'o'; | 611 foo_chars[2] = 'o'; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 CHECK_EQ(84, captures[4]); | 655 CHECK_EQ(84, captures[4]); |
| 654 | 656 |
| 655 const uc16 str2[] = {'b', 'a', 'r', 'f', 'o', 'o'}; | 657 const uc16 str2[] = {'b', 'a', 'r', 'f', 'o', 'o'}; |
| 656 Handle<String> f2_16 = | 658 Handle<String> f2_16 = |
| 657 Factory::NewStringFromTwoByte(Vector<const uc16>(str2, 6)); | 659 Factory::NewStringFromTwoByte(Vector<const uc16>(str2, 6)); |
| 658 | 660 |
| 659 CHECK(!IrregexpInterpreter::Match(array, f2_16, captures, 0)); | 661 CHECK(!IrregexpInterpreter::Match(array, f2_16, captures, 0)); |
| 660 CHECK_EQ(42, captures[0]); | 662 CHECK_EQ(42, captures[0]); |
| 661 } | 663 } |
| 662 | 664 |
| 663 | 665 #ifdef V8_TARGET_ARCH_IA32 // IA32 Native Regexp only tests. |
| 664 #ifdef V8_TARGET_ARCH_IA32 // IA32 only tests. | 666 #ifdef V8_NATIVE_REGEXP |
| 665 | 667 |
| 666 class ContextInitializer { | 668 class ContextInitializer { |
| 667 public: | 669 public: |
| 668 ContextInitializer() : env_(), scope_(), stack_guard_() { | 670 ContextInitializer() : env_(), scope_(), stack_guard_() { |
| 669 env_ = v8::Context::New(); | 671 env_ = v8::Context::New(); |
| 670 env_->Enter(); | 672 env_->Enter(); |
| 671 } | 673 } |
| 672 ~ContextInitializer() { | 674 ~ContextInitializer() { |
| 673 env_->Exit(); | 675 env_->Exit(); |
| 674 env_.Dispose(); | 676 env_.Dispose(); |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 captures, | 1279 captures, |
| 1278 true); | 1280 true); |
| 1279 | 1281 |
| 1280 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 1282 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); |
| 1281 CHECK_EQ(0, captures[0]); | 1283 CHECK_EQ(0, captures[0]); |
| 1282 CHECK_EQ(42, captures[1]); | 1284 CHECK_EQ(42, captures[1]); |
| 1283 | 1285 |
| 1284 Top::clear_pending_exception(); | 1286 Top::clear_pending_exception(); |
| 1285 } | 1287 } |
| 1286 | 1288 |
| 1289 #endif // V8_REGEXP_NATIVE |
| 1290 #endif // V8_TARGET_ARCH_IA32 |
| 1287 | 1291 |
| 1288 | 1292 |
| 1289 #endif // !defined ARM | |
| 1290 | |
| 1291 TEST(AddInverseToTable) { | 1293 TEST(AddInverseToTable) { |
| 1292 static const int kLimit = 1000; | 1294 static const int kLimit = 1000; |
| 1293 static const int kRangeCount = 16; | 1295 static const int kRangeCount = 16; |
| 1294 for (int t = 0; t < 10; t++) { | 1296 for (int t = 0; t < 10; t++) { |
| 1295 ZoneScope zone_scope(DELETE_ON_EXIT); | 1297 ZoneScope zone_scope(DELETE_ON_EXIT); |
| 1296 ZoneList<CharacterRange>* ranges = | 1298 ZoneList<CharacterRange>* ranges = |
| 1297 new ZoneList<CharacterRange>(kRangeCount); | 1299 new ZoneList<CharacterRange>(kRangeCount); |
| 1298 for (int i = 0; i < kRangeCount; i++) { | 1300 for (int i = 0; i < kRangeCount; i++) { |
| 1299 int from = PseudoRandom(t + 87, i + 25) % kLimit; | 1301 int from = PseudoRandom(t + 87, i + 25) % kLimit; |
| 1300 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20)); | 1302 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20)); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 CHECK(!InClass(i, excluded)); | 1529 CHECK(!InClass(i, excluded)); |
| 1528 } | 1530 } |
| 1529 } | 1531 } |
| 1530 } | 1532 } |
| 1531 | 1533 |
| 1532 | 1534 |
| 1533 TEST(Graph) { | 1535 TEST(Graph) { |
| 1534 V8::Initialize(NULL); | 1536 V8::Initialize(NULL); |
| 1535 Execute("(?:(?:x(.))?\1)+$", false, true, true); | 1537 Execute("(?:(?:x(.))?\1)+$", false, true, true); |
| 1536 } | 1538 } |
| OLD | NEW |