Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/xslt/xpath/txNumberResult.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
/**
7
 * NumberResult
8
 * Represents the a number as the result of evaluating an Expr
9
**/
10
11
#include "mozilla/FloatingPoint.h"
12
13
#include "txExprResult.h"
14
15
/**
16
 * Default Constructor
17
**/
18
19
/**
20
 * Creates a new NumberResult with the value of the given double parameter
21
 * @param dbl the double to use for initialization of this NumberResult's value
22
**/
23
NumberResult::NumberResult(double aValue, txResultRecycler* aRecycler)
24
    : txAExprResult(aRecycler), value(aValue)
25
0
{
26
0
} //-- NumberResult
27
28
/*
29
 * Virtual Methods from ExprResult
30
*/
31
32
0
short NumberResult::getResultType() {
33
0
    return txAExprResult::NUMBER;
34
0
} //-- getResultType
35
36
void
37
NumberResult::stringValue(nsString& aResult)
38
0
{
39
0
    txDouble::toString(value, aResult);
40
0
}
41
42
const nsString*
43
NumberResult::stringValuePointer()
44
0
{
45
0
    return nullptr;
46
0
}
47
48
0
bool NumberResult::booleanValue() {
49
0
  // OG+
50
0
  // As per the XPath spec, the boolean value of a number is true if and only if
51
0
  // it is neither positive 0 nor negative 0 nor NaN
52
0
  return (bool)(value != 0.0 && !mozilla::IsNaN(value));
53
0
  // OG-
54
0
} //-- booleanValue
55
56
0
double NumberResult::numberValue() {
57
0
    return this->value;
58
0
} //-- numberValue
59