Bruce Jay Mack - iCIS Knowledge base and Collaboration WikiWiki
Welcome Guest, you are in: Login

Test Wiki

RSS RSS

Navigation





Search the wiki
»

PoweredBy

Generate Column Fixture Table with Random Data

RSS
Modified on 02/23/2015 07:16 by Administrator Categorized as Column Fixture, Data


  1. !/usr/bin/perl
  2. (c) 2002 Cunningham & Cunningham, Inc.

use strict; print "Content-type: text/html\n\n";

my ($x, $y, $z, $t) = (0,0,0,0); my $date = `date`; my $version = '1.0.3';

my $rows = 30; $rows = $1 if $ENV{QUERY_STRING} =~ /\brows=(\d+)\b/;

sub simulate { for (1..$rows) { $_ = int(rand(8)); /0/ && &enter(rand()); /1/ && &enter(-rand()); /2/ && &enter(rand(10000)); /3/ && &enter(-rand(10000)); /4/ && &press('+'); /5/ && &press('-'); /6/ && &press('*'); /7/ && &press('/'); } }

sub enter { my $entry = substr($_0,0,10); ($x, $y, $z, $t) = ($entry, $x, $y, $z); &row($entry); }

sub press { my $result = eval("$y $_0 $x")+0; ($x, $y, $z, $t) = ($result, $z, $t, $t); &row($_0); }

sub row { print <<; <tr> <td>$_0</td> <td>$x</td> <td>$y</td> <td>$z</td> <td>$t</td> </tr>

}

  1. Note use of <wiki> ... </wiki> tags to be compatible with
  2. wiki generated html expected by the run.cgi script.

print <<; <html><body> <h1>Model Generated Test Data<br>for the HP-35 Calculator</h1> <p> A model of the HP-35 calculator has been implemented in perl and used to generate the self consistent randomized test data which is reported below. You can save this particular data using your browser's <i>Save As</i> menu. You can also try one of the following. </p> <ul> <li> Generate <a href=hp35.cgi>more</a> test data. <li> Use data like this to <a href=run.cgi>run</a> the test. <li> Read the <a href=hp35.txt>source</a> of the generator. </ul> <wiki> <table border cellspacing=0 cellpadding=3> <tr> <td colspan=5>eg.Calculator</td> </tr> <tr> <td>key</td> <td>x()</td> <td>y()</td> <td>z()</td> <td>t()</td> </tr>

&simulate();

print <<; </table> </wiki> <p> Test data generated $date<br> with version $version generator. </p> </body> </html>





 

ScrewTurn Wiki version 3.0.5.600. Some of the icons created by FamFamFam.