CS685 - Homework #1 - Hello World

Page Contents:

  1. Introduction
  2. Applet
  3. Source Code
  4. Analysis

1. Introduction

This was my first project for CS685, due 1998-09-15. It might have also been my first applet; I don't remember. I think the main point of the assignment was to get us to write about the testing process.

2. Applet

Instructions:

3. Source Code

I formatted the source code into HTML using java2html.pl, which I found on the Web and modified slightly.

4. Analysis

There are 65536 valid input tokens: integers between 0 and 65535, inclusive. Half are even, half are odd. Each even input needs to cause "Hello World" to be written and the program ready for the next input, to which it must react in the same manner. Each odd input needs to cause "Goodbye World" to be written and the program terminated (no more input will be read).

The entire valid input for one execution of the program consists of an arbitrarily long sequence of valid even numbers followed by one valid odd number.

There is no way to test every single valid sequence of inputs, since sequences of even numbers can be arbitrarily long. For instance, there's no way to be sure that I didn't add "Easter Egg" logic to my program that forces the 666th even number input to result in "Hello Satan" instead of "Hello World," or more generally, that for each N from 1 to infinity, the Nth even number entered results in "Hello World" being printed and the machine returned to a receptive state.

Since we cannot test an infinite number of infinitely long input sequences, we will never be able to exhaustively test the program. There is no proof-logical benefit in exhaustively testing valid sequences of 1000 numbers of less, or even 100, 10, 5, or 2 numbers.

The only thing we can do is make sure that when one even number is entered, the machine prints "Hello World" and then appears to be ready for the next input. [i.e., we can assume that it's ready if the input field is still there, and if we enter a "2" it prints another "Hello World" and after a "1" it prints "Goodbye World."]

Therefore, we only need to run one test for each of the even inputs, and of course one test for each of the odd inputs. So, 65536 tests total.

note: this is the computer theoretical answer. In reality, I would want to test at least a couple levels of input deep; however, the question was phrased theoretically, not practically.

Each test takes 1 nanosecond, so the total testing time will be 65536 nanoseconds.

1 ns = 10E-9 s = 10^-9s / (60s/m * 60m/h * 24 h/d * 365.25d/y * 10E+9y/AU) = 3.1688 * 10E-26 AU

So, total testing time = (65536 * 3.1688 * 10E-26 AU) = 2.0767 * 10E-21 AU