OLD | NEW |
(Empty) | |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 // Load CSV Parser and Log Reader implementations from <project root>/tools. |
| 29 // Files: tools/csvparser.js tools/logreader.js |
| 30 |
| 31 |
| 32 (function testAddressParser() { |
| 33 var reader = new devtools.profiler.LogReader({}); |
| 34 var parser = reader.createAddressParser('test'); |
| 35 |
| 36 // Test that 0x values are parsed, and prevAddresses_ are untouched. |
| 37 assertFalse('test' in reader.prevAddresses_); |
| 38 assertEquals(0, parser('0x0')); |
| 39 assertFalse('test' in reader.prevAddresses_); |
| 40 assertEquals(0x100, parser('0x100')); |
| 41 assertFalse('test' in reader.prevAddresses_); |
| 42 assertEquals(0xffffffff, parser('0xffffffff')); |
| 43 assertFalse('test' in reader.prevAddresses_); |
| 44 |
| 45 // Test that values that has no '+' or '-' prefix are parsed |
| 46 // and saved to prevAddresses_. |
| 47 assertEquals(0, parser('0')); |
| 48 assertEquals(0, reader.prevAddresses_.test); |
| 49 assertEquals(0x100, parser('100')); |
| 50 assertEquals(0x100, reader.prevAddresses_.test); |
| 51 assertEquals(0xffffffff, parser('ffffffff')); |
| 52 assertEquals(0xffffffff, reader.prevAddresses_.test); |
| 53 |
| 54 // Test that values prefixed with '+' or '-' are treated as deltas, |
| 55 // and prevAddresses_ is updated. |
| 56 // Set base value. |
| 57 assertEquals(0x100, parser('100')); |
| 58 assertEquals(0x100, reader.prevAddresses_.test); |
| 59 assertEquals(0x200, parser('+100')); |
| 60 assertEquals(0x200, reader.prevAddresses_.test); |
| 61 assertEquals(0x100, parser('-100')); |
| 62 assertEquals(0x100, reader.prevAddresses_.test); |
| 63 })(); |
| 64 |
| 65 |
| 66 (function testAddressParser() { |
| 67 var reader = new devtools.profiler.LogReader({}); |
| 68 |
| 69 assertEquals([0x10000000, 0x10001000, 0xffff000, 0x10000000], |
| 70 reader.processStack(0x10000000, 0, ['overflow', |
| 71 '+1000', '-2000', '+1000'])); |
| 72 })(); |
| 73 |
| 74 |
| 75 (function testExpandBackRef() { |
| 76 var reader = new devtools.profiler.LogReader({}); |
| 77 |
| 78 assertEquals('aaaaaaaa', reader.expandBackRef_('aaaaaaaa')); |
| 79 assertEquals('aaaaaaaa', reader.expandBackRef_('#1')); |
| 80 assertEquals('bbbbaaaa', reader.expandBackRef_('bbbb#2:4')); |
| 81 assertEquals('"#1:1"', reader.expandBackRef_('"#1:1"')); |
| 82 })(); |
OLD | NEW |