| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 
 | // Tags: JDK1.5
//  This file is part of Mauve.
//  update for strictfp modifier Pavel Tisnovsky <ptisnovs@redhat.com>
//  Mauve is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2, or (at your option)
//  any later version.
//  Mauve is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//  You should have received a copy of the GNU General Public License
//  along with Mauve; see the file COPYING.  If not, write to
//  the Free Software Foundation, 59 Temple Place - Suite 330,
//  Boston, MA 02111-1307, USA.
package gnu.testlet.java.lang.Math.strictfp_modifier;
import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
/**
  * Test for a static method Math.expm1()
  * by using strictfp modifier.
  */
public strictfp class expm1 implements Testlet
{
  /**
   * Function (=static method) checked by this test.
   */
  private static double testedFunction(double input)
    {
      return Math.expm1(input);
    }
  /**
   * These values are used as arguments to expm1.
   * The values are somewhat arbitrary, but ensure that all code paths
   * are tested.
   */
  private static double[] inputValues =
    {
      0.0,
      Double.NaN,
      Double.POSITIVE_INFINITY,
      Double.NEGATIVE_INFINITY,
      0.0000000000000000277555756156289135105,   // ~ 2^-55
      -0.0000000000000000277555756156289135105,  // ~ -2^55
      0.6 * 0.6931471805599453 + 0.05,           // 0.6 * ln(2) + 0.05
      -0.6 * 0.6931471805599453 - 0.05,          // -0.6 * ln(2) - 0.05
      0.25 * 0.6931471805599453 + 0.03,          // 0.25 * ln(2) + 0.03
      -0.25 * 0.6931471805599453 - 0.03,         // -0.25 * ln(2) - 0.03
      0.44,
      -0.44,
      2.3 * 0.6931471805599453 + 0.05,           // 2.3 * ln(2) + 0.05
      -2.3 * 0.6931471805599453 - 0.05,          // -2.3 * ln(2) - 0.05
      7 * 0.6931471805599453 + 0.03,             // 7 * ln(2) + 0.03
      -9 * 0.6931471805599453 - 0.03,            // -9 * ln(2) - 0.03
      29 * 0.6931471805599453 + 0.03,            // 29 * ln(2) + 0.03
      -27 * 0.6931471805599453 - 0.03,           // -27 * ln(2) - 0.03
      709.782712893384,                          //  EXP_LIMIT_H
      709.782712893384 + 3.423e-5,               //  EXP_LIMIT_H + 3.423e-5
      709.782712893384 - 3.423e-5,               //  EXP_LIMIT_H - 3.423e-5
      -709.782712893384,                         // -EXP_LIMIT_H
      -709.782712893384 - 3.423e-5,              // -EXP_LIMIT_H - 3.423e-5
      -709.782712893384 + 3.423e-5               // -EXP_LIMIT_H + 3.423e-5
    };
  /**
   * These values are the expected results, obtained from the RI.
   */
  private static double[] outputValues =
    {
      0.0,
      Double.NaN,
      Double.POSITIVE_INFINITY,
      -1.0,
      2.7755575615628914E-17,
      -2.7755575615628914E-17,
      0.5934290166706889,
      -0.3724226247056801,
      0.22542386346433524,
      -0.1839558296400811,
      0.5527072185113361,
      -0.35596357891685865,
      4.177066148857307,
      -0.806840405116183,
      130.89818034605017,
      -0.9981045985672881,
      5.532210644181606E8,
      -0.9999999927696174,
      1.7976931348622732E308,
      Double.POSITIVE_INFINITY,
      1.7976316008794578E308,
      -1.0,
      -1.0,
      -1.0
    };
  /**
    * These values represent various NaN
    */
  private static long[] NaNValues =
    {
      0x7fff800000000000L,
      0xffff800000000000L,
      0x7fff812345abcdefL,
      0xffff812345abcdefL,
      0x7fff000000000001L,
      0xffff000000000001L,
      0x7fff7654321fedcbL,
      0xffff7654321fedcbL
    };
  /**
   * Test not NaN values.
   */
  private void testInputValues(TestHarness harness)
  {
    double res;
    for (int i = 0; i < inputValues.length; ++i)
      {
	res = testedFunction(inputValues[i]);
	// exact equality
	harness.check(Double.doubleToLongBits(res), Double.doubleToLongBits(outputValues[i]));
      }
  }
  /**
   * Test if input NaN is returned unchanged.
   */
  private void testNaN(TestHarness harness)
  {
    long   bitsNaN;
    double valNaN;
    for (int i = 0; i < NaNValues.length; ++i)
      {
	bitsNaN = NaNValues[i];
	valNaN  = Double.longBitsToDouble(bitsNaN);
	// exact equality
	harness.check(Double.doubleToRawLongBits(testedFunction(valNaN)),
		      bitsNaN);
      }
  }
  /**
    * Entry point to a test.
    */
  public void test(TestHarness harness)
  {
    testInputValues(harness);
    testNaN(harness);
  }
  /**
   * Run this on the RI to obtain the expected output values.
   */
  public static void main(String[] argv)
  {
    for (int i = 0; i < inputValues.length; ++i)
      {
    double input = inputValues[i];
    double output = testedFunction(inputValues[i]);
	System.out.println("      " + Double.toString(output) + ", // " + input);
      }
  }
}
 |