Timid Ninja !

It is during our darkest moments that we must focus to see the light.

Ini merupakan hasil compile dari source program


Source program
 
/*
* MathExploreToy.java
*
* Created on June, 2003, 7:17 pm
*/
/**
*
*@author Bambang Haryanto, Ir.MT
*Inspired by Deitel, page 268
*
*/
public class MathExploreToy{

 /** Creates a new instance of MathExploreToy */
 public MathExploreToy(){
 
}
 static void test(){
  testE();
  testPI();
  testAbs();
 }
 
 static void betterTest(){
  testIntAbs();
 }
 
 static void testE(){
  System.out.println ("Testing untuk Math.E");
  System.out.println ("Math.E = "+Math.E);
  System.out.println ("");
 }
 static void testPI(){
  System.out.println("Testing untuk Math.PI");
  System.out.println("Math.PI= "+Math.PI);
  System.out.println("");
  }
 static void testAbs(){
  System.out.println ("Testing untuk Math.abs()");
  System.out.println ("Math.abs (-23.7) = "+Math.abs(-23.7));
  System.out.println ("Math.abs (0.0) = "+Math.abs(0.0));
  System.out.println ("Math.abs (23-7) = "+Math.abs(23.7));
  System.out.println ("Double.MIN_VALUES = "+Double.MIN_VALUE);
  System.out.println ("Math.abs(Double.MIN_VALUES) = "+Math.abs(Double.MIN_VALUE));
  System.out.println ("Math.abs(-Double.MIN_VALUE) = "+Math.abs(-Double.MIN_VALUE));
  System.out.println ("Double.MAX_Value = "+Double.MAX_VALUE);
  System.out.println ("Math.abs(Double.MAX_VALUE) = "+Math.abs(Double.MAX_VALUE));
  System.out.println ("Math.abs(-Double.MAX_VALUE) = "+Math.abs(Double.MAX_VALUE));
  System.out.println ("");
 }
 
 static void testIntAbs(){
  System.out.println ("Cara pengujian yang lebih baik - mendukung otomatisasi!");
  System.out.println ("Testing untuk Math.abs() bagi bilangan bulat");
  if (Math.abs(-23) != 23) System.out.println("Math(-23)::Error! Hasil harus 23");
  else System.out.println ("Math(-23):: Correct!");
  
  if (Math.abs(0) != 0) System.out.println("Math(0)::Error! Hasil harus 0");
  else System.out.println ("Math(0):: Correct!");
  
  if (Math.abs(23) != 23) System.out.println("Math(23)::Error! Hasil harus 23");
  else System.out.println("Math(23):: Correct!");
  
  System.out.println ("Integer.MIN_VALUE = "+Integer.MIN_VALUE);
  System.out.println ("Math.abs(Integer.MIN_VALUE) = "+Math.abs(Integer.MIN_VALUE));
  System.out.println ("Integer.MAX_VALUE = "+Integer.MAX_VALUE);
  if (Math.abs(Integer.MIN_VALUE)!= -Integer.MIN_VALUE) System.out.println("Math.abs(Integer.MIN_VALUE::Error!)");
  else System.out.println ("Math.abs(Integer.MIN_VALUE:: Correct!");
  
  if (Math.abs(Integer.MIN_VALUE)<0 data-blogger-escaped-ath="" data-blogger-escaped-error="" data-blogger-escaped-harus="" data-blogger-escaped-hasil="" data-blogger-escaped-nteger.min_value="" data-blogger-escaped-system.out.println="">0");
  else System.out.println ("Math(Integer.MIN_VALUE)::Correct!");
  
  if (Math.abs(Integer.MAX_VALUE)!= Integer.MAX_VALUE) System.out.println ("Math(Integer.MAX_VALUE):: Error!");
  else System.out.println ("Math(Integer.MAX_VALUE):: Correct!");
  
  System.out.println ("\n\nPERHATIAN!");
  System.out.println ("Pengujian menunjukan hasil yang tidak sesuai dengan matematika!!!\n"+"Pada kondisi batas sangat sulit diprediksi, untuk itu kita harus mengacu dokumentasi bahasa\n"+ "Pengujian otomatis kadang tidak dapat mengemukakannya secara benar karena dibatasi juga \n" + "oleh kemampuan bahasa itu sendiri bila kesalahan adalah pada spesifikasi bahasa itu sendiri!\n"+"pengujian otomatis akan benar ditangani oleh para ahli, pengujian dapat ditambah sbb:\n"+"Berdasarkan kenyataan bahwa hasil fungsi abs tidak boleh kurang dari nol");
  System.out.println ("\n"+ "Di Java, Math.abs (Integer.MIN_VALUE) justru menghasilkan bilangan negatif. \n"+ "Melanggar rumus matematika dimana hasil fungsi absolut selalu bernilai positif.\n"+ "hasil ini dapat ditelusuri karena representasi int adalah two's complement\n"+ "versi yang dipakai penulis:: JDK1.4");
 }
 static void testAcos(){
  System.out.println ("Math.acos(0.9)="+Math.acos(0.9));
 }
 static void testCeil(){
 }
 static void testCos(){
 }
 static void testExp(){
 }
 static void testFloor(){
 }
 static void testLog(){
 }
 static void testMax(){
 }
 static void testMin(){
 }
 static void testPow(){
 }
 static void testSin(){
 }
 static void testSqrt(){
 }
 static void testTan(){
 }
 
 public static void main (String[] args){
  test();
  betterTest();
 }
 
}
Inti dari program ini adalah pengetesan terhadap suatu program yang tidak sesuai dengan bentuk bahasa pemrogramannya dalam kasus ini Java. Sebagai contoh metode diatas akan memperlihatkan hasil program di layar yang dapat memeriksa kebenaran antar muka seperti konstanta E dan konstanta PI dan metode metode di kelas.
Selanjutnya pengujian akan menggunakan otomatisasi dimana akan muncur kata Error! Bila terdapat kesalahan pada program tersebut, tetapi kita tidak bisa mengandalkan fasilitas bahasa seperti kasus diatas, karena Java terkadang tidak sesuai dengan fungsi matematika sepenuhnya dan dibutuhkan pengujian agar tidak merugikan di lain kesempatan

0 komentar:

Posting Komentar

Student Site

BAAK Gunadarma

Berita Student Site

Total Tayangan Halaman

Diberdayakan oleh Blogger.