diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index d7ba7d7c7d..6bf092dafe 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -331,16 +331,14 @@ static uint16_t* AsciiToTwoByteString(const char* source) { class TestResource: public String::ExternalStringResource { public: - static int dispose_count; - - explicit TestResource(uint16_t* data) - : data_(data), length_(0) { + explicit TestResource(uint16_t* data, int* counter = NULL) + : data_(data), length_(0), counter_(counter) { while (data[length_]) ++length_; } ~TestResource() { i::DeleteArray(data_); - ++dispose_count; + if (counter_ != NULL) ++*counter_; } const uint16_t* data() const { @@ -353,23 +351,18 @@ class TestResource: public String::ExternalStringResource { private: uint16_t* data_; size_t length_; + int* counter_; }; -int TestResource::dispose_count = 0; - - class TestAsciiResource: public String::ExternalAsciiStringResource { public: - static int dispose_count; - - explicit TestAsciiResource(const char* data) - : data_(data), - length_(strlen(data)) { } + explicit TestAsciiResource(const char* data, int* counter = NULL) + : data_(data), length_(strlen(data)), counter_(counter) { } ~TestAsciiResource() { i::DeleteArray(data_); - ++dispose_count; + if (counter_ != NULL) ++*counter_; } const char* data() const { @@ -382,20 +375,18 @@ class TestAsciiResource: public String::ExternalAsciiStringResource { private: const char* data_; size_t length_; + int* counter_; }; -int TestAsciiResource::dispose_count = 0; - - THREADED_TEST(ScriptUsingStringResource) { - TestResource::dispose_count = 0; + int dispose_count = 0; const char* c_source = "1 + 2 * 3"; uint16_t* two_byte_source = AsciiToTwoByteString(c_source); { v8::HandleScope scope; LocalContext env; - TestResource* resource = new TestResource(two_byte_source); + TestResource* resource = new TestResource(two_byte_source, &dispose_count); Local source = String::NewExternal(resource); Local