From 715f2617dffdcede45af45e5e849cb83f67745b4 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 17 Jan 2009 07:27:25 +0000 Subject: Make makefixed.pl round to nearest integer, rather than truncating towards zero. Add a test for negative fractions to properties.dat svn path=/trunk/libcss/; revision=6110 --- test/data/parse/makefixed.pl | 12 +++++++++++- test/data/parse/properties.dat | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'test/data') diff --git a/test/data/parse/makefixed.pl b/test/data/parse/makefixed.pl index 712784f..1a9306f 100755 --- a/test/data/parse/makefixed.pl +++ b/test/data/parse/makefixed.pl @@ -7,5 +7,15 @@ die "Usage: makefixed.pl \n" if (@ARGV != 1); my $val = shift @ARGV; -printf("0x%.8x\n", $val * (1 << 10)); +$val *= (1 << 10); + +# Round away from zero +if ($val < 0) { + $val -= 0.5; +} else { + $val += 0.5; +} + +# Truncates back towards zero +printf("0x%.8x\n", $val); diff --git a/test/data/parse/properties.dat b/test/data/parse/properties.dat index c2f4f48..bc09a04 100644 --- a/test/data/parse/properties.dat +++ b/test/data/parse/properties.dat @@ -122,6 +122,14 @@ | 0x02000000 0x00000324 0x00000202 #reset +#data +* { azimuth: -0.785rad; } +#errors +#expected +| 1 * +| 0x02000000 0xfffffcdc 0x00000202 +#reset + ## ## 01 - background-attachment ## -- cgit v1.2.3