PageRenderTime 26ms CodeModel.GetById 23ms RepoModel.GetById 0ms 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
Possible License(s): Apache-2.0
  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. package com.google.test.metric;
  32. public class CostUtil {
  33. // This adds a global cost of 1 to everything else in the class. No matter
  34. // if it is a primitive or Object -- any time you have globaly mutable state
  35. // (non-final static state), you will have hard to test code. (And hard to
  36. // parallelize code).
  37. private static boolean x = false;
  38. public static boolean staticCost0() {
  39. return x;
  40. }
  41. public boolean instanceCost0() {
  42. return x;
  43. }
  44. public static boolean staticCost1() {
  45. boolean a = x ? false : true;
  46. return a;
  47. }
  48. public boolean instanceCost1() {
  49. boolean a = x ? false : true;
  50. return a;
  51. }
  52. public static boolean staticCost2() {
  53. boolean a = x ? false : true;
  54. boolean b = a ? false : true;
  55. return b;
  56. }
  57. public boolean instanceCost2() {
  58. boolean a = x ? false : true;
  59. boolean b = a ? false : true;
  60. return b;
  61. }
  62. public static boolean staticCost3() {
  63. boolean a = x ? false : true;
  64. boolean b = a ? false : true;
  65. boolean c = b ? false : true;
  66. return c;
  67. }
  68. public boolean instanceCost3() {
  69. boolean a = x ? false : true;
  70. boolean b = a ? false : true;
  71. boolean c = b ? false : true;
  72. return c;
  73. }
  74. public static boolean staticCost4() {
  75. boolean a = x ? false : true;
  76. boolean b = a ? false : true;
  77. boolean c = b ? false : true;
  78. boolean d = c ? false : true;
  79. return d;
  80. }
  81. public boolean instanceCost4() {
  82. boolean a = x ? false : true;
  83. boolean b = a ? false : true;
  84. boolean c = b ? false : true;
  85. boolean d = c ? false : true;
  86. return d;
  87. }
  88. }