Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
|
Jakob Kummerow
2012/02/22 11:36:06
nit: 2012
| |
| 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 29 | 29 |
| 30 #include "v8.h" | 30 #include "v8.h" |
| 31 | 31 |
| 32 #include "data-flow.h" | 32 #include "data-flow.h" |
| 33 #include "cctest.h" | 33 #include "cctest.h" |
| 34 | 34 |
| 35 using namespace v8::internal; | 35 using namespace v8::internal; |
| 36 | 36 |
| 37 TEST(BitVector) { | 37 TEST(BitVector) { |
| 38 v8::internal::V8::Initialize(NULL); | 38 v8::internal::V8::Initialize(NULL); |
| 39 ZoneScope zone(Isolate::Current(), DELETE_ON_EXIT); | 39 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); |
| 40 Zone* zone = ZONE; | |
| 40 { | 41 { |
| 41 BitVector v(15); | 42 BitVector v(15, zone); |
| 42 v.Add(1); | 43 v.Add(1); |
| 43 CHECK(v.Contains(1)); | 44 CHECK(v.Contains(1)); |
| 44 v.Remove(0); | 45 v.Remove(0); |
| 45 CHECK(!v.Contains(0)); | 46 CHECK(!v.Contains(0)); |
| 46 v.Add(0); | 47 v.Add(0); |
| 47 v.Add(1); | 48 v.Add(1); |
| 48 BitVector w(15); | 49 BitVector w(15, zone); |
| 49 w.Add(1); | 50 w.Add(1); |
| 50 v.Intersect(w); | 51 v.Intersect(w); |
| 51 CHECK(!v.Contains(0)); | 52 CHECK(!v.Contains(0)); |
| 52 CHECK(v.Contains(1)); | 53 CHECK(v.Contains(1)); |
| 53 } | 54 } |
| 54 | 55 |
| 55 { | 56 { |
| 56 BitVector v(64); | 57 BitVector v(64, zone); |
| 57 v.Add(27); | 58 v.Add(27); |
| 58 v.Add(30); | 59 v.Add(30); |
| 59 v.Add(31); | 60 v.Add(31); |
| 60 v.Add(33); | 61 v.Add(33); |
| 61 BitVector::Iterator iter(&v); | 62 BitVector::Iterator iter(&v); |
| 62 CHECK_EQ(27, iter.Current()); | 63 CHECK_EQ(27, iter.Current()); |
| 63 iter.Advance(); | 64 iter.Advance(); |
| 64 CHECK_EQ(30, iter.Current()); | 65 CHECK_EQ(30, iter.Current()); |
| 65 iter.Advance(); | 66 iter.Advance(); |
| 66 CHECK_EQ(31, iter.Current()); | 67 CHECK_EQ(31, iter.Current()); |
| 67 iter.Advance(); | 68 iter.Advance(); |
| 68 CHECK_EQ(33, iter.Current()); | 69 CHECK_EQ(33, iter.Current()); |
| 69 iter.Advance(); | 70 iter.Advance(); |
| 70 CHECK(iter.Done()); | 71 CHECK(iter.Done()); |
| 71 } | 72 } |
| 72 | 73 |
| 73 { | 74 { |
| 74 BitVector v(15); | 75 BitVector v(15, zone); |
| 75 v.Add(0); | 76 v.Add(0); |
| 76 BitVector w(15); | 77 BitVector w(15, zone); |
| 77 w.Add(1); | 78 w.Add(1); |
| 78 v.Union(w); | 79 v.Union(w); |
| 79 CHECK(v.Contains(0)); | 80 CHECK(v.Contains(0)); |
| 80 CHECK(v.Contains(1)); | 81 CHECK(v.Contains(1)); |
| 81 } | 82 } |
| 82 | 83 |
| 83 { | 84 { |
| 84 BitVector v(15); | 85 BitVector v(15, zone); |
| 85 v.Add(0); | 86 v.Add(0); |
| 86 BitVector w(15); | 87 BitVector w(15, zone); |
| 87 w = v; | 88 w = v; |
| 88 CHECK(w.Contains(0)); | 89 CHECK(w.Contains(0)); |
| 89 w.Add(1); | 90 w.Add(1); |
| 90 BitVector u(w); | 91 BitVector u(w, zone); |
| 91 CHECK(u.Contains(0)); | 92 CHECK(u.Contains(0)); |
| 92 CHECK(u.Contains(1)); | 93 CHECK(u.Contains(1)); |
| 93 v.Union(w); | 94 v.Union(w); |
| 94 CHECK(v.Contains(0)); | 95 CHECK(v.Contains(0)); |
| 95 CHECK(v.Contains(1)); | 96 CHECK(v.Contains(1)); |
| 96 } | 97 } |
| 97 | 98 |
| 98 { | 99 { |
| 99 BitVector v(35); | 100 BitVector v(35, zone); |
| 100 v.Add(0); | 101 v.Add(0); |
| 101 BitVector w(35); | 102 BitVector w(35, zone); |
| 102 w.Add(33); | 103 w.Add(33); |
| 103 v.Union(w); | 104 v.Union(w); |
| 104 CHECK(v.Contains(0)); | 105 CHECK(v.Contains(0)); |
| 105 CHECK(v.Contains(33)); | 106 CHECK(v.Contains(33)); |
| 106 } | 107 } |
| 107 | 108 |
| 108 { | 109 { |
| 109 BitVector v(35); | 110 BitVector v(35, zone); |
| 110 v.Add(32); | 111 v.Add(32); |
| 111 v.Add(33); | 112 v.Add(33); |
| 112 BitVector w(35); | 113 BitVector w(35, zone); |
| 113 w.Add(33); | 114 w.Add(33); |
| 114 v.Intersect(w); | 115 v.Intersect(w); |
| 115 CHECK(!v.Contains(32)); | 116 CHECK(!v.Contains(32)); |
| 116 CHECK(v.Contains(33)); | 117 CHECK(v.Contains(33)); |
| 117 BitVector r(35); | 118 BitVector r(35, zone); |
| 118 r.CopyFrom(v); | 119 r.CopyFrom(v); |
| 119 CHECK(!r.Contains(32)); | 120 CHECK(!r.Contains(32)); |
| 120 CHECK(r.Contains(33)); | 121 CHECK(r.Contains(33)); |
| 121 } | 122 } |
| 122 } | 123 } |
| OLD | NEW |