PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/testability-explorer/src/test/java/com/google/test/metric/CostUtil.java

http://testability-explorer.googlecode.com/
Java | 100 lines | 54 code | 12 blank | 34 comment | 0 complexity | d720fa92ac3ed4f14ef77eeed1aa0c5c MD5 | raw file
  1/*
  2 * Copyright 2007 Google Inc.
  3 *
  4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5 * use this file except in compliance with the License. You may obtain a copy of
  6 * the License at
  7 *
  8 * http://www.apache.org/licenses/LICENSE-2.0
  9 *
 10 * Unless required by applicable law or agreed to in writing, software
 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 13 * License for the specific language governing permissions and limitations under
 14 * the License.
 15 */
 16/*
 17 * Copyright 2007 Google Inc.
 18 *
 19 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 20 * use this file except in compliance with the License. You may obtain a copy of
 21 * the License at
 22 *
 23 * http://www.apache.org/licenses/LICENSE-2.0
 24 *
 25 * Unless required by applicable law or agreed to in writing, software
 26 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 27 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 28 * License for the specific language governing permissions and limitations under
 29 * the License.
 30 */
 31
 32package com.google.test.metric;
 33
 34public class CostUtil {
 35  // This adds a global cost of 1 to everything else in the class. No matter
 36  // if it is a primitive or Object -- any time you have globaly mutable state
 37  // (non-final static state), you will have hard to test code.  (And hard to
 38  // parallelize code).
 39  private static boolean x = false;
 40
 41  public static boolean staticCost0() {
 42    return x;
 43  }
 44
 45  public boolean instanceCost0() {
 46    return x;
 47  }
 48
 49  public static boolean staticCost1() {
 50    boolean a = x ? false : true;
 51    return a;
 52  }
 53
 54  public boolean instanceCost1() {
 55    boolean a = x ? false : true;
 56    return a;
 57  }
 58
 59  public static boolean staticCost2() {
 60    boolean a = x ? false : true;
 61    boolean b = a ? false : true;
 62    return b;
 63  }
 64
 65  public boolean instanceCost2() {
 66    boolean a = x ? false : true;
 67    boolean b = a ? false : true;
 68    return b;
 69  }
 70
 71  public static boolean staticCost3() {
 72    boolean a = x ? false : true;
 73    boolean b = a ? false : true;
 74    boolean c = b ? false : true;
 75    return c;
 76  }
 77
 78  public boolean instanceCost3() {
 79    boolean a = x ? false : true;
 80    boolean b = a ? false : true;
 81    boolean c = b ? false : true;
 82    return c;
 83  }
 84
 85  public static boolean staticCost4() {
 86    boolean a = x ? false : true;
 87    boolean b = a ? false : true;
 88    boolean c = b ? false : true;
 89    boolean d = c ? false : true;
 90    return d;
 91  }
 92
 93  public boolean instanceCost4() {
 94    boolean a = x ? false : true;
 95    boolean b = a ? false : true;
 96    boolean c = b ? false : true;
 97    boolean d = c ? false : true;
 98    return d;
 99  }
100}