| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2010 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 #include <stdlib.h> |
| 29 |
| 30 #include "v8.h" |
| 31 |
| 32 #include "data-flow.h" |
| 33 #include "cctest.h" |
| 34 |
| 35 using namespace v8::internal; |
| 36 |
| 37 TEST(BitVector) { |
| 38 ZoneScope zone(DELETE_ON_EXIT); |
| 39 { |
| 40 BitVector v(15); |
| 41 v.Add(1); |
| 42 CHECK(v.Contains(1)); |
| 43 v.Remove(0); |
| 44 CHECK(!v.Contains(0)); |
| 45 v.Add(0); |
| 46 v.Add(1); |
| 47 BitVector w(15); |
| 48 w.Add(1); |
| 49 v.Intersect(w); |
| 50 CHECK(!v.Contains(0)); |
| 51 CHECK(v.Contains(1)); |
| 52 } |
| 53 |
| 54 { |
| 55 BitVector v(15); |
| 56 v.Add(0); |
| 57 BitVector w(15); |
| 58 w.Add(1); |
| 59 v.Union(w); |
| 60 CHECK(v.Contains(0)); |
| 61 CHECK(v.Contains(1)); |
| 62 } |
| 63 |
| 64 { |
| 65 BitVector v(15); |
| 66 v.Add(0); |
| 67 BitVector w(15); |
| 68 w = v; |
| 69 CHECK(w.Contains(0)); |
| 70 w.Add(1); |
| 71 BitVector u(w); |
| 72 CHECK(u.Contains(0)); |
| 73 CHECK(u.Contains(1)); |
| 74 v.Union(w); |
| 75 CHECK(v.Contains(0)); |
| 76 CHECK(v.Contains(1)); |
| 77 } |
| 78 |
| 79 { |
| 80 BitVector v(35); |
| 81 v.Add(0); |
| 82 BitVector w(35); |
| 83 w.Add(33); |
| 84 v.Union(w); |
| 85 CHECK(v.Contains(0)); |
| 86 CHECK(v.Contains(33)); |
| 87 } |
| 88 |
| 89 { |
| 90 BitVector v(35); |
| 91 v.Add(32); |
| 92 v.Add(33); |
| 93 BitVector w(35); |
| 94 w.Add(33); |
| 95 v.Intersect(w); |
| 96 CHECK(!v.Contains(32)); |
| 97 CHECK(v.Contains(33)); |
| 98 BitVector r(35); |
| 99 r.CopyFrom(v); |
| 100 CHECK(!r.Contains(32)); |
| 101 CHECK(r.Contains(33)); |
| 102 } |
| 103 } |
| OLD | NEW |