Bug 968520 - Add mozilla::fallible to FallibleArray calls in tests. r=froydnj
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Mon, 08 Jun 2015 13:39:49 -0700
changeset 270979 117d25cbd07c1680aa38a9563e7cfc2d12898870
parent 270978 c3dceefa3b20d053f51ba11e6e5d8ad28e2c0deb
child 270980 ca04ee4db747731f83172023a5f1cc41a2d5dece
push id2738
push userwcosta@mozilla.com
push dateWed, 10 Jun 2015 13:39:02 +0000
reviewersfroydnj
bugs968520
milestone41.0a1
Bug 968520 - Add mozilla::fallible to FallibleArray calls in tests. r=froydnj
xpcom/glue/tests/gtest/TestGCPostBarriers.cpp
xpcom/tests/TestTArray.cpp
--- a/xpcom/glue/tests/gtest/TestGCPostBarriers.cpp
+++ b/xpcom/glue/tests/gtest/TestGCPostBarriers.cpp
@@ -53,17 +53,17 @@ RunTest(JSRuntime* rt, JSContext* cx, Ar
    */
   RootedValue value(cx);
   const char* property = "foo";
   for (size_t i = 0; i < ElementCount; ++i) {
     RootedObject obj(cx, JS_NewPlainObject(cx));
     ASSERT_FALSE(JS::ObjectIsTenured(obj));
     value = Int32Value(i);
     ASSERT_TRUE(JS_SetProperty(cx, obj, property, value));
-    array->AppendElement(obj);
+    ASSERT_TRUE(array->AppendElement(obj, fallible));
   }
 
   /*
    * If postbarriers are not working, we will crash here when we try to mark
    * objects that have been moved to the tenured heap.
    */
   JS_GC(rt);
 
--- a/xpcom/tests/TestTArray.cpp
+++ b/xpcom/tests/TestTArray.cpp
@@ -1006,17 +1006,17 @@ static bool test_fallible()
 
   // Allocate a bunch of 128MB arrays.  Larger allocations will fail on some
   // platforms without actually hitting OOM.
   //
   // 36 * 128MB > 4GB, so we should definitely OOM by the 36th array.
   const unsigned numArrays = 36;
   FallibleTArray<char> arrays[numArrays];
   for (size_t i = 0; i < numArrays; i++) {
-    bool success = arrays[i].SetCapacity(128 * 1024 * 1024);
+    bool success = arrays[i].SetCapacity(128 * 1024 * 1024, fallible);
     if (!success) {
       // We got our OOM.  Check that it didn't come too early.
       if (i < 8) {
         printf("test_fallible: Got OOM on iteration %d.  Too early!\n", int(i));
         return false;
       }
       return true;
     }
@@ -1107,17 +1107,17 @@ static bool test_SetLengthAndRetainStora
     pre fauto post;                                            \
     pre i post;                                                \
     pre iauto post;                                            \
     pre t post;                                                \
     pre tauto post;                                            \
   } while (0)
   
   // Setup test arrays.
-  FOR_EACH(;, .SetLength(N));
+  FOR_EACH(;, .SetLength(N, fallible));
   for (int n = 0; n < N; ++n) {
     FOR_EACH(;, [n] = n);
   }
 
   void* initial_Hdrs[] = {
     static_cast<BufAccessor<FallibleTArray<int> >&>(f).GetHdr(),
     static_cast<BufAccessor<AutoFallibleTArray<int, N> >&>(fauto).GetHdr(),
     static_cast<BufAccessor<InfallibleTArray<int> >&>(i).GetHdr(),