Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allstarschh/a3bc437f2acb94a0949ddf784fbc6fc6 to your computer and use it in GitHub Desktop.
Save allstarschh/a3bc437f2acb94a0949ddf784fbc6fc6 to your computer and use it in GitHub Desktop.
commit 545b774a1f9622fe9fc9f775ff62481d6d23e9e5
Author: Yoshi Cheng-Hao Huang <allstars.chh@gmail.com>
Date: Tue Jun 2 19:39:48 2020 +0200
test Rooted<JSLinearString*>
diff --git a/js/src/jsapi-tests/moz.build b/js/src/jsapi-tests/moz.build
index 77ce80711e5f..6c86873210fc 100644
--- a/js/src/jsapi-tests/moz.build
+++ b/js/src/jsapi-tests/moz.build
@@ -64,16 +64,17 @@ UNIFIED_SOURCES += [
'testIndexToString.cpp',
'testInformalValueTypeName.cpp',
'testIntern.cpp',
'testIntlAvailableLocales.cpp',
'testIntString.cpp',
'testIsInsideNursery.cpp',
'testIteratorObject.cpp',
'testJSEvaluateScript.cpp',
+ 'testJSLinearString.cpp',
'testLookup.cpp',
'testLooselyEqual.cpp',
'testMappedArrayBuffer.cpp',
'testMemoryAssociation.cpp',
'testMutedErrors.cpp',
'testNewObject.cpp',
'testNewTargetInvokeConstructor.cpp',
'testNullRoot.cpp',
diff --git a/js/src/jsapi-tests/testJSLinearString.cpp b/js/src/jsapi-tests/testJSLinearString.cpp
new file mode 100644
index 000000000000..b4623a8b183a
--- /dev/null
+++ b/js/src/jsapi-tests/testJSLinearString.cpp
@@ -0,0 +1,17 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "jsapi-tests/tests.h"
+
+using namespace JS;
+
+BEGIN_TEST(test_LinearString) {
+ JSString* str = JS_NewStringCopyZ(cx, "hello");
+ JS::RootedString rs(cx, str);
+ if (!rs) return false;
+ JS::Rooted<JSLinearString*> rls(cx, JS_EnsureLinearString(cx, rs));
+ if (!rls) return false;
+ return true;
+}
+END_TEST(test_LinearString)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment