Here are some example of fit tests, integrated in ZWiki? pages for convenient editing (cf ZWiki:ZwikiAndFit).

Here's the original FitWiki:SimpleExample. First, Division.py in ZWiki/fixtures/ looks like this:

from fit.ColumnFixture import ColumnFixture class Division(ColumnFixture): numerator = 0.0 denominator = 0.0 def quotient(self): return self.numerator / self.denominator

A table like this has been entered on this page (using HTML):

don't process this one fixtures.Division | ||

numerator | denominator | quotient() |

1000 | 10 | 100.0000 |

-1000 | 10 | -100.0000 |

1000 | 7 | 142.85715 |

1000 | .00001 | 100000000 |

1000 | 0 | INF |

0 | 0 | NaN? |

4195835 | 3145729 | 1.3338196 |

and here it is processed by fit (you should see cells highlighted red or green and perhaps annotated, according to the test results):

fixtures.Division | ||

numerator | denominator | quotient() |

1000 | 10 | 100.0000 |

-1000 | 10 | -100.0000 |

1000 | 7 | 142.85715 |

1000 | .00001 | 100000000 |

1000 | 0 | INF |

0 | 0 | NaN? |

4195835 | 3145729 | 1.3338196 |

As you can see, some tests fail because of differences between java and python's arithmetic (and also differences between the java and python fit implementations - python fit infers types from the format of the test data). Here's how you would need to tweak these tests to pass with python fit:

fixtures.Division | ||

numerator | denominator | quotient() |

1000.0 | 10.0 | 100.0 |

-1000.0 | 10.0 | -100.0 |

1000.0 | 7.0 | 142.85714285714286 |

1000.0 | .00001 | 99999999.999999985 |

1000.0 | 0.0 | error |

0.0 | 0.0 | error |

4195835.0 | 3145729 | 1.3338196011163073 |

Here's fit's arithmetic.html example, again highlighting python/java arithmetic differences:

fixtures.ArithmeticFixture | |||||

x | y | + | - | * | / |

0 | 0 | 0 | 0 | 0 | 0 |

1 | 2 | 3 | -1 | 2 | 0.5 |

1 | -1 | 0 | 2 | -1 | -1 |

10000 | 10000 | 20000 | 0 | 100000000 | 1 |

100000 | 100000 | 200000 | 0 | 10000000000 | 1 |

1000000 | 1000000 | 2000000 | 0 | 1000000000000 | 1 |

fixtures.ArithmeticColumnFixture | |||||

x | y | plus() | times() | divide() | floating() |

2 | 3 | 5 | 6 | 0 | 0.666667 |

0 | 0 | 0 | 0 | error | error |

0 | 0 | 0 | 0 | ||

200 | 300 | 500 | 60000 | 0 | 0.666667 |

2 | 3 | 10 | 10 | 10 | |

200 | 3 | 5 | 6 | 0 | 0.666667 |

2 | -3 | -1 | -6 | -0 | -0.666667 |

fit.Summary generates a summary. These counts should reset on each page view, but don't:

fit.Summary |

MusicExample has some more tests.

**doesn't work?** --Bill Page, Mon, 14 Aug 2006 18:56:18 -0700 reply

I guess this stuff doesn't work any more?

**doesn't work?** --simon, Mon, 14 Aug 2006 19:04:20 -0700 reply

I think it still works, if you have fit installed in the right place (and I don't). I'll fix that if someone finds a way to use this.