From 9e3f123cd55f60c28d242a264463b8d1730585f1 Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Mon, 29 Jun 2015 17:08:19 +0300 Subject: [PATCH] Fix character code values for "" and "" characters in ecma-char helpers. JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com --- jerry-core/ecma/base/ecma-helpers-char.cpp | 4 ++-- tests/jerry/new-line-in-literal.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tests/jerry/new-line-in-literal.js diff --git a/jerry-core/ecma/base/ecma-helpers-char.cpp b/jerry-core/ecma/base/ecma-helpers-char.cpp index 1f0196efa..9cd7a5ca8 100644 --- a/jerry-core/ecma/base/ecma-helpers-char.cpp +++ b/jerry-core/ecma/base/ecma-helpers-char.cpp @@ -32,7 +32,7 @@ bool ecma_char_is_new_line (ecma_char_t c) /**< character value */ { - return (c == '\x0D'); + return (c == '\x0A'); } /* ecma_char_is_new_line */ /** @@ -44,7 +44,7 @@ ecma_char_is_new_line (ecma_char_t c) /**< character value */ bool ecma_char_is_carriage_return (ecma_char_t c) /**< character value */ { - return (c == '\x0A'); + return (c == '\x0D'); } /* ecma_char_is_carriage_return */ /** diff --git a/tests/jerry/new-line-in-literal.js b/tests/jerry/new-line-in-literal.js new file mode 100644 index 000000000..b11048178 --- /dev/null +++ b/tests/jerry/new-line-in-literal.js @@ -0,0 +1,17 @@ +// Copyright 2015 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +assert (eval ("'1\\\r\n2'") === '12'); + +assert (eval ("'1\\\n2'") === '12');