js/src/jsapi-tests/testErrorCopying.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jsapi-tests/testErrorCopying.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,35 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99:
     1.6 + *
     1.7 + * Tests that the column number of error reports is properly copied over from
     1.8 + * other reports when invoked from the C++ api.
     1.9 + */
    1.10 +/* This Source Code Form is subject to the terms of the Mozilla Public
    1.11 + * License, v. 2.0. If a copy of the MPL was not distributed with this
    1.12 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.13 +
    1.14 +#include "jsapi-tests/tests.h"
    1.15 +
    1.16 +static uint32_t column = 0;
    1.17 +
    1.18 +BEGIN_TEST(testErrorCopying_columnCopied)
    1.19 +{
    1.20 +        //0         1         2
    1.21 +        //0123456789012345678901234567
    1.22 +    EXEC("function check() { Object; foo; }");
    1.23 +
    1.24 +    JS::RootedValue rval(cx);
    1.25 +    JS_SetErrorReporter(cx, my_ErrorReporter);
    1.26 +    CHECK(!JS_CallFunctionName(cx, global, "check", JS::HandleValueArray::empty(),
    1.27 +                               &rval));
    1.28 +    CHECK(column == 27);
    1.29 +    return true;
    1.30 +}
    1.31 +
    1.32 +static void
    1.33 +my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
    1.34 +{
    1.35 +    column = report->column;
    1.36 +}
    1.37 +
    1.38 +END_TEST(testErrorCopying_columnCopied)

mercurial