File: fuzzy.testscript

package info (click to toggle)
tcllib 1.20%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 68,064 kB
  • sloc: tcl: 216,842; ansic: 14,250; sh: 2,846; xml: 1,766; yacc: 1,145; pascal: 881; makefile: 107; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (21 lines) | stat: -rw-r--r-- 586 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Rough tests for math::fuzzy procs
# To do: convert to Tcltest

package require math::fuzzy
namespace import ::math::fuzzy::*

puts "[teq 1.0 1.001] - expected: 0"
puts "[teq 1.0 1.0000000000000000001] - expected: 1"
puts "[tne 1.0 1.001] - expected: 1"
puts "[tne 1.0 1.0000000000000000001] - expected: 0"
puts "[tgt 1.0 1.001] - expected: 0"
puts "[tgt 1.0 1.0000000000000000001] - expected: 0"

set x 0.11
set y [expr {(($x*11.0)-$x)-0.1}]
set z 1.0
puts "X: $x"
puts "Y: $y"
puts "Z: $z"
puts "Floor: [tfloor $y] ([expr {floor($y)}])"
puts "Ceil:  [tceil  $y] ([expr {ceil($y)}])"