cairo 1.6.1-x86-mswin32 → 1.7.0-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of cairo might be problematic. Click here for more details.
- data/ChangeLog +285 -0
- data/NEWS +33 -0
- data/README +15 -4
- data/Rakefile +3 -0
- data/cairo/bin/libcairo-2.dll +0 -0
- data/cairo/bin/libpng12-0.dll +0 -0
- data/cairo/include/{libpng13/png.h → png.h} +285 -135
- data/cairo/include/{libpng13/pngconf.h → pngconf.h} +116 -72
- data/cairo/lib/cairo.lib +0 -0
- data/cairo/lib/libcairo.dll.a +0 -0
- data/cairo/lib/libpng.def +361 -371
- data/cairo/lib/libpng.lib +0 -0
- data/cairo/lib/libpng12.dll.a +0 -0
- data/cairo/lib/pkgconfig/cairo-pdf.pc +1 -1
- data/cairo/lib/pkgconfig/cairo-png.pc +2 -2
- data/cairo/lib/pkgconfig/cairo-ps.pc +1 -1
- data/cairo/lib/pkgconfig/cairo-svg.pc +1 -1
- data/cairo/lib/pkgconfig/cairo-win32-font.pc +1 -1
- data/cairo/lib/pkgconfig/cairo-win32.pc +1 -1
- data/cairo/lib/pkgconfig/cairo.pc +2 -2
- data/cairo/lib/pkgconfig/libpng.pc +10 -14
- data/cairo/lib/pkgconfig/libpng12.pc +10 -0
- data/cairo/make/{cairo-1.6.4-1.sh → cairo-1.6.4-2.sh} +3 -3
- data/cairo/make/libpng-1.2.29.sh +35 -0
- data/cairo/manifest/cairo-1.6.4-2.mft +6 -0
- data/cairo/manifest/{cairo-dev-1.6.4-1.mft → cairo-dev-1.6.4-2.mft} +2 -2
- data/cairo/manifest/libpng-1.2.29.mft +2 -0
- data/cairo/manifest/libpng-dev-1.2.29.mft +12 -0
- data/cairo/share/doc/{cairo-1.6.4-1 → cairo-1.6.4-2}/COPYING +0 -0
- data/cairo/share/doc/{cairo-1.6.4-1 → cairo-1.6.4-2}/COPYING-LGPL-2.1 +0 -0
- data/cairo/share/doc/{cairo-1.6.4-1 → cairo-1.6.4-2}/COPYING-MPL-1.1 +0 -0
- data/cairo/share/man/man3/libpng.3 +3680 -0
- data/cairo/share/man/man3/libpngpf.3 +274 -0
- data/cairo/share/man/man5/png.5 +74 -0
- data/doc/en/cairo-antialias.html +0 -3
- data/doc/en/cairo-clip-not-representable-error.html +0 -3
- data/doc/en/cairo-color-base.html +0 -3
- data/doc/en/cairo-color-cmyk.html +0 -3
- data/doc/en/cairo-color-hsv.html +0 -3
- data/doc/en/cairo-color-rgb.html +0 -3
- data/doc/en/cairo-color-x11.html +0 -3
- data/doc/en/cairo-color.html +0 -3
- data/doc/en/cairo-content.html +0 -3
- data/doc/en/cairo-context-blur.html +0 -3
- data/doc/en/cairo-context-circle.html +0 -3
- data/doc/en/cairo-context-color.html +0 -3
- data/doc/en/cairo-context-path.html +0 -3
- data/doc/en/cairo-context-rectangle.html +0 -3
- data/doc/en/cairo-context-triangle.html +0 -3
- data/doc/en/cairo-context.html +119 -102
- data/doc/en/cairo-error.html +0 -3
- data/doc/en/cairo-extend.html +0 -3
- data/doc/en/cairo-file-not-found.html +0 -3
- data/doc/en/cairo-fill-rule.html +0 -3
- data/doc/en/cairo-filter.html +0 -3
- data/doc/en/cairo-font-extents.html +67 -12
- data/doc/en/cairo-font-face.html +0 -3
- data/doc/en/cairo-font-options.html +26 -14
- data/doc/en/cairo-font-slant.html +0 -3
- data/doc/en/cairo-font-type-mismatch.html +47 -0
- data/doc/en/cairo-font-weight.html +0 -3
- data/doc/en/cairo-format.html +0 -3
- data/doc/en/cairo-glyph.html +0 -3
- data/doc/en/cairo-gradient-pattern.html +0 -3
- data/doc/en/cairo-hint-metrics.html +0 -3
- data/doc/en/cairo-hint-style.html +0 -3
- data/doc/en/cairo-image-surface.html +0 -3
- data/doc/en/cairo-invalid-clusters.html +47 -0
- data/doc/en/cairo-invalid-content-error.html +0 -3
- data/doc/en/cairo-invalid-dash-error.html +0 -3
- data/doc/en/cairo-invalid-dsc-comment-error.html +0 -3
- data/doc/en/cairo-invalid-format-error.html +0 -3
- data/doc/en/cairo-invalid-index-error.html +0 -3
- data/doc/en/cairo-invalid-matrix-error.html +0 -3
- data/doc/en/cairo-invalid-path-data-error.html +0 -3
- data/doc/en/cairo-invalid-pop-group-error.html +0 -3
- data/doc/en/cairo-invalid-restore-error.html +0 -3
- data/doc/en/cairo-invalid-slant.html +47 -0
- data/doc/en/cairo-invalid-status-error.html +0 -3
- data/doc/en/cairo-invalid-stride-error.html +0 -3
- data/doc/en/cairo-invalid-string-error.html +0 -3
- data/doc/en/cairo-invalid-visual-error.html +0 -3
- data/doc/en/cairo-invalid-weight.html +47 -0
- data/doc/en/cairo-lcd-filter.html +39 -0
- data/doc/en/cairo-line-cap.html +0 -3
- data/doc/en/cairo-line-join.html +0 -3
- data/doc/en/cairo-linear-pattern.html +0 -3
- data/doc/en/cairo-matrix.html +43 -41
- data/doc/en/cairo-negative-count.html +47 -0
- data/doc/en/cairo-no-current-point-error.html +0 -3
- data/doc/en/cairo-null-pointer-error.html +0 -3
- data/doc/en/cairo-operator.html +0 -3
- data/doc/en/cairo-paper-parse-error.html +0 -3
- data/doc/en/cairo-paper-unknown-paper-name.html +0 -3
- data/doc/en/cairo-paper-unknown-unit.html +0 -3
- data/doc/en/cairo-paper-unrecognized-paper-description.html +0 -3
- data/doc/en/cairo-paper.html +0 -3
- data/doc/en/cairo-path-close-path.html +0 -3
- data/doc/en/cairo-path-curve-to.html +0 -3
- data/doc/en/cairo-path-data-type.html +0 -3
- data/doc/en/cairo-path-data.html +0 -3
- data/doc/en/cairo-path-line-to.html +0 -3
- data/doc/en/cairo-path-move-to.html +0 -3
- data/doc/en/cairo-path.html +0 -3
- data/doc/en/cairo-pattern-type-mismatch-error.html +0 -3
- data/doc/en/cairo-pattern.html +0 -3
- data/doc/en/cairo-pdf-surface.html +0 -3
- data/doc/en/cairo-point.html +0 -3
- data/doc/en/cairo-ps-level.html +0 -3
- data/doc/en/cairo-ps-surface.html +0 -3
- data/doc/en/cairo-quartz-image-surface.html +0 -3
- data/doc/en/cairo-quartz-surface.html +0 -3
- data/doc/en/cairo-radial-pattern.html +0 -3
- data/doc/en/cairo-read-error.html +0 -3
- data/doc/en/cairo-rectangle.html +0 -3
- data/doc/en/cairo-scaled-font.html +13 -6
- data/doc/en/cairo-solid-pattern.html +0 -3
- data/doc/en/cairo-subpixel-order.html +0 -3
- data/doc/en/cairo-surface-finished-error.html +0 -3
- data/doc/en/cairo-surface-pattern.html +0 -3
- data/doc/en/cairo-surface-type-mismatch-error.html +0 -3
- data/doc/en/cairo-surface.html +22 -15
- data/doc/en/cairo-svg-surface.html +0 -3
- data/doc/en/cairo-svg-version.html +0 -3
- data/doc/en/cairo-temp-file-error.html +0 -3
- data/doc/en/cairo-text-cluster.html +84 -0
- data/doc/en/cairo-text-extents.html +78 -13
- data/doc/en/cairo-toy-font-face.html +67 -0
- data/doc/en/cairo-user-font-error.html +47 -0
- data/doc/en/cairo-user-font-face-text-to-glyphs-data.html +94 -0
- data/doc/en/cairo-user-font-face.html +72 -0
- data/doc/en/cairo-user-font-immutable.html +47 -0
- data/doc/en/cairo-win32-printing-surface.html +0 -3
- data/doc/en/cairo-win32-surface.html +0 -3
- data/doc/en/cairo-write-error.html +0 -3
- data/doc/en/cairo.html +92 -80
- data/doc/en/index.html +327 -240
- data/doc/ja/cairo-clip-not-representable-error.html +1 -1
- data/doc/ja/cairo-color-base.html +1 -1
- data/doc/ja/cairo-color-cmyk.html +9 -9
- data/doc/ja/cairo-color-hsv.html +8 -8
- data/doc/ja/cairo-color-rgb.html +9 -9
- data/doc/ja/cairo-color.html +8 -8
- data/doc/ja/cairo-context-circle.html +1 -1
- data/doc/ja/cairo-context-color.html +1 -1
- data/doc/ja/cairo-context-path.html +2 -2
- data/doc/ja/cairo-context.html +435 -342
- data/doc/ja/cairo-font-extents.html +69 -15
- data/doc/ja/cairo-font-face.html +3 -3
- data/doc/ja/cairo-font-options.html +37 -12
- data/doc/ja/cairo-font-slant.html +1 -1
- data/doc/ja/cairo-font-type-mismatch.html +52 -0
- data/doc/ja/cairo-glyph.html +5 -5
- data/doc/ja/cairo-gradient-pattern.html +6 -6
- data/doc/ja/cairo-image-surface.html +8 -8
- data/doc/ja/cairo-invalid-clusters.html +55 -0
- data/doc/ja/cairo-invalid-restore-error.html +1 -1
- data/doc/ja/cairo-invalid-slant.html +57 -0
- data/doc/ja/cairo-invalid-weight.html +57 -0
- data/doc/ja/cairo-lcd-filter.html +63 -0
- data/doc/ja/cairo-line-join.html +1 -1
- data/doc/ja/cairo-linear-pattern.html +2 -2
- data/doc/ja/cairo-matrix.html +35 -24
- data/doc/ja/cairo-negative-count.html +52 -0
- data/doc/ja/cairo-paper-unknown-paper-name.html +2 -2
- data/doc/ja/cairo-paper-unknown-unit.html +2 -2
- data/doc/ja/cairo-paper-unrecognized-paper-description.html +1 -1
- data/doc/ja/cairo-paper.html +12 -12
- data/doc/ja/cairo-path-close-path.html +1 -1
- data/doc/ja/cairo-path-curve-to.html +1 -1
- data/doc/ja/cairo-path-data.html +8 -8
- data/doc/ja/cairo-path-line-to.html +1 -1
- data/doc/ja/cairo-path-move-to.html +1 -1
- data/doc/ja/cairo-path.html +21 -21
- data/doc/ja/cairo-pattern.html +4 -4
- data/doc/ja/cairo-pdf-surface.html +2 -2
- data/doc/ja/cairo-point.html +5 -5
- data/doc/ja/cairo-ps-level.html +2 -2
- data/doc/ja/cairo-ps-surface.html +6 -6
- data/doc/ja/cairo-quartz-image-surface.html +2 -2
- data/doc/ja/cairo-quartz-surface.html +3 -3
- data/doc/ja/cairo-radial-pattern.html +2 -2
- data/doc/ja/cairo-rectangle.html +5 -5
- data/doc/ja/cairo-scaled-font.html +53 -17
- data/doc/ja/cairo-solid-pattern.html +3 -3
- data/doc/ja/cairo-surface-pattern.html +2 -2
- data/doc/ja/cairo-surface.html +58 -36
- data/doc/ja/cairo-svg-surface.html +4 -4
- data/doc/ja/cairo-svg-version.html +2 -2
- data/doc/ja/cairo-text-cluster.html +102 -0
- data/doc/ja/cairo-text-extents.html +84 -22
- data/doc/ja/cairo-toy-font-face.html +107 -0
- data/doc/ja/cairo-user-font-error.html +55 -0
- data/doc/ja/cairo-user-font-face-text-to-glyphs-data.html +155 -0
- data/doc/ja/cairo-user-font-face.html +268 -0
- data/doc/ja/cairo-user-font-immutable.html +54 -0
- data/doc/ja/cairo-win32-printing-surface.html +3 -3
- data/doc/ja/cairo-win32-surface.html +4 -4
- data/doc/ja/cairo.html +110 -77
- data/doc/ja/index.html +292 -205
- data/extconf.rb +3 -1
- data/misc/update-colors.rb +0 -0
- data/pkg-config.rb +54 -28
- data/samples/agg/aa_test.rb +0 -0
- data/samples/blur.rb +0 -0
- data/samples/png.rb +0 -0
- data/samples/scalable.rb +0 -0
- data/samples/text-on-path.rb +0 -0
- data/samples/text2.rb +0 -0
- data/src/cairo.def +8 -0
- data/src/cairo.so +0 -0
- data/src/lib/cairo.rb +12 -7
- data/src/lib/cairo/constants.rb +1 -0
- data/src/libruby-cairo.a +0 -0
- data/src/rb_cairo.c +25 -3
- data/src/rb_cairo.h +29 -18
- data/src/rb_cairo_constants.c +39 -10
- data/src/rb_cairo_context.c +156 -15
- data/src/rb_cairo_exception.c +143 -3
- data/src/rb_cairo_font_extents.c +81 -6
- data/src/rb_cairo_font_face.c +646 -4
- data/src/rb_cairo_font_options.c +24 -2
- data/src/rb_cairo_glyph.c +5 -3
- data/src/rb_cairo_matrix.c +17 -1
- data/src/rb_cairo_pattern.c +4 -4
- data/src/rb_cairo_private.c +169 -5
- data/src/rb_cairo_private.h +45 -3
- data/src/rb_cairo_scaled_font.c +61 -3
- data/src/rb_cairo_surface.c +174 -59
- data/src/rb_cairo_text_cluster.c +151 -0
- data/src/rb_cairo_text_extents.c +85 -2
- data/test-unit/Rakefile +30 -0
- data/test-unit/bin/testrb +5 -0
- data/test-unit/lib/test/unit.rb +280 -0
- data/test-unit/lib/test/unit/assertionfailederror.rb +14 -0
- data/test-unit/lib/test/unit/assertions.rb +722 -0
- data/test-unit/lib/test/unit/attribute.rb +125 -0
- data/test-unit/lib/test/unit/autorunner.rb +254 -0
- data/test-unit/lib/test/unit/collector.rb +43 -0
- data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
- data/test-unit/lib/test/unit/collector/dir.rb +108 -0
- data/test-unit/lib/test/unit/collector/load.rb +135 -0
- data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
- data/test-unit/lib/test/unit/color.rb +61 -0
- data/test-unit/lib/test/unit/diff.rb +524 -0
- data/test-unit/lib/test/unit/error.rb +124 -0
- data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
- data/test-unit/lib/test/unit/failure.rb +110 -0
- data/test-unit/lib/test/unit/fixture.rb +185 -0
- data/test-unit/lib/test/unit/notification.rb +125 -0
- data/test-unit/lib/test/unit/omission.rb +143 -0
- data/test-unit/lib/test/unit/pending.rb +146 -0
- data/test-unit/lib/test/unit/priority.rb +146 -0
- data/test-unit/lib/test/unit/runner/console.rb +46 -0
- data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
- data/test-unit/lib/test/unit/testcase.rb +281 -0
- data/test-unit/lib/test/unit/testresult.rb +89 -0
- data/test-unit/lib/test/unit/testsuite.rb +110 -0
- data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +195 -0
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +49 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +20 -0
- data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
- data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
- data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
- data/test-unit/lib/test/unit/util/observable.rb +90 -0
- data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
- data/test-unit/lib/test/unit/version.rb +7 -0
- data/test-unit/sample/adder.rb +13 -0
- data/test-unit/sample/subtracter.rb +12 -0
- data/test-unit/sample/tc_adder.rb +18 -0
- data/test-unit/sample/tc_subtracter.rb +18 -0
- data/test-unit/sample/ts_examples.rb +7 -0
- data/test-unit/test/collector/test_descendant.rb +135 -0
- data/test-unit/test/collector/test_dir.rb +406 -0
- data/test-unit/test/collector/test_load.rb +333 -0
- data/test-unit/test/collector/test_objectspace.rb +98 -0
- data/test-unit/test/run-test.rb +13 -0
- data/test-unit/test/test_assertions.rb +693 -0
- data/test-unit/test/test_attribute.rb +86 -0
- data/test-unit/test/test_color.rb +37 -0
- data/test-unit/test/test_diff.rb +477 -0
- data/test-unit/test/test_emacs_runner.rb +60 -0
- data/test-unit/test/test_error.rb +26 -0
- data/test-unit/test/test_failure.rb +33 -0
- data/test-unit/test/test_fixture.rb +252 -0
- data/test-unit/test/test_notification.rb +33 -0
- data/test-unit/test/test_omission.rb +81 -0
- data/test-unit/test/test_pending.rb +70 -0
- data/test-unit/test/test_priority.rb +89 -0
- data/test-unit/test/test_testcase.rb +430 -0
- data/test-unit/test/test_testresult.rb +113 -0
- data/test-unit/test/test_testsuite.rb +129 -0
- data/test-unit/test/testunit_test_util.rb +14 -0
- data/test-unit/test/ui/test_testrunmediator.rb +20 -0
- data/test-unit/test/util/test_backtracefilter.rb +41 -0
- data/test-unit/test/util/test_observable.rb +102 -0
- data/test-unit/test/util/test_procwrapper.rb +36 -0
- data/test/cairo-test-utils.rb +18 -0
- data/test/run-test.rb +14 -1
- data/test/test_constants.rb +19 -0
- data/test/test_context.rb +117 -0
- data/test/test_exception.rb +27 -0
- data/test/test_font_extents.rb +36 -0
- data/test/test_font_face.rb +244 -0
- data/test/test_font_options.rb +32 -0
- data/test/test_pkg_config.rb +3 -2
- data/test/test_scaled_font.rb +34 -0
- data/test/test_surface.rb +41 -0
- data/test/test_text_cluster.rb +32 -0
- data/test/test_text_extents.rb +40 -0
- data/test/test_text_to_glyphs_data.rb +47 -0
- metadata +129 -109
- data/cairo/bin/libpng13.dll +0 -0
- data/cairo/lib/libpng13.dll.a +0 -0
- data/cairo/lib/pkgconfig/libpng13.pc +0 -14
- data/cairo/manifest/cairo-1.6.4-1.mft +0 -6
- data/cairo/manifest/libpng-dev-1.2.8.mft +0 -7
- data/doc/en/cairo-antialias.rd +0 -16
- data/doc/en/cairo-clip-not-representable-error.rd +0 -17
- data/doc/en/cairo-color-base.rd +0 -38
- data/doc/en/cairo-color-cmyk.rd +0 -107
- data/doc/en/cairo-color-hsv.rd +0 -91
- data/doc/en/cairo-color-rgb.rd +0 -95
- data/doc/en/cairo-color-x11.rd +0 -151
- data/doc/en/cairo-color.rd +0 -213
- data/doc/en/cairo-content.rd +0 -15
- data/doc/en/cairo-context-blur.rd +0 -15
- data/doc/en/cairo-context-circle.rd +0 -15
- data/doc/en/cairo-context-color.rd +0 -15
- data/doc/en/cairo-context-path.rd +0 -19
- data/doc/en/cairo-context-rectangle.rd +0 -15
- data/doc/en/cairo-context-triangle.rd +0 -15
- data/doc/en/cairo-context.rd +0 -491
- data/doc/en/cairo-error.rd +0 -16
- data/doc/en/cairo-extend.rd +0 -16
- data/doc/en/cairo-file-not-found.rd +0 -17
- data/doc/en/cairo-fill-rule.rd +0 -14
- data/doc/en/cairo-filter.rd +0 -18
- data/doc/en/cairo-font-extents.rd +0 -40
- data/doc/en/cairo-font-face.rd +0 -14
- data/doc/en/cairo-font-options.rd +0 -94
- data/doc/en/cairo-font-slant.rd +0 -15
- data/doc/en/cairo-font-weight.rd +0 -14
- data/doc/en/cairo-format.rd +0 -22
- data/doc/en/cairo-glyph.rd +0 -62
- data/doc/en/cairo-gradient-pattern.rd +0 -41
- data/doc/en/cairo-hint-metrics.rd +0 -15
- data/doc/en/cairo-hint-style.rd +0 -17
- data/doc/en/cairo-image-surface.rd +0 -47
- data/doc/en/cairo-invalid-content-error.rd +0 -17
- data/doc/en/cairo-invalid-dash-error.rd +0 -17
- data/doc/en/cairo-invalid-dsc-comment-error.rd +0 -17
- data/doc/en/cairo-invalid-format-error.rd +0 -17
- data/doc/en/cairo-invalid-index-error.rd +0 -17
- data/doc/en/cairo-invalid-matrix-error.rd +0 -17
- data/doc/en/cairo-invalid-path-data-error.rd +0 -17
- data/doc/en/cairo-invalid-pop-group-error.rd +0 -17
- data/doc/en/cairo-invalid-restore-error.rd +0 -17
- data/doc/en/cairo-invalid-status-error.rd +0 -17
- data/doc/en/cairo-invalid-stride-error.rd +0 -17
- data/doc/en/cairo-invalid-string-error.rd +0 -17
- data/doc/en/cairo-invalid-visual-error.rd +0 -17
- data/doc/en/cairo-line-cap.rd +0 -15
- data/doc/en/cairo-line-join.rd +0 -15
- data/doc/en/cairo-linear-pattern.rd +0 -28
- data/doc/en/cairo-matrix.rd +0 -186
- data/doc/en/cairo-no-current-point-error.rd +0 -17
- data/doc/en/cairo-null-pointer-error.rd +0 -17
- data/doc/en/cairo-operator.rd +0 -26
- data/doc/en/cairo-paper-parse-error.rd +0 -17
- data/doc/en/cairo-paper-unknown-paper-name.rd +0 -30
- data/doc/en/cairo-paper-unknown-unit.rd +0 -30
- data/doc/en/cairo-paper-unrecognized-paper-description.rd +0 -30
- data/doc/en/cairo-paper.rd +0 -141
- data/doc/en/cairo-path-close-path.rd +0 -21
- data/doc/en/cairo-path-curve-to.rd +0 -21
- data/doc/en/cairo-path-data-type.rd +0 -16
- data/doc/en/cairo-path-data.rd +0 -62
- data/doc/en/cairo-path-line-to.rd +0 -21
- data/doc/en/cairo-path-move-to.rd +0 -21
- data/doc/en/cairo-path.rd +0 -109
- data/doc/en/cairo-pattern-type-mismatch-error.rd +0 -17
- data/doc/en/cairo-pattern.rd +0 -62
- data/doc/en/cairo-pdf-surface.rd +0 -27
- data/doc/en/cairo-point.rd +0 -42
- data/doc/en/cairo-ps-level.rd +0 -24
- data/doc/en/cairo-ps-surface.rd +0 -55
- data/doc/en/cairo-quartz-image-surface.rd +0 -27
- data/doc/en/cairo-quartz-surface.rd +0 -27
- data/doc/en/cairo-radial-pattern.rd +0 -28
- data/doc/en/cairo-read-error.rd +0 -17
- data/doc/en/cairo-rectangle.rd +0 -54
- data/doc/en/cairo-scaled-font.rd +0 -50
- data/doc/en/cairo-solid-pattern.rd +0 -31
- data/doc/en/cairo-subpixel-order.rd +0 -17
- data/doc/en/cairo-surface-finished-error.rd +0 -17
- data/doc/en/cairo-surface-pattern.rd +0 -27
- data/doc/en/cairo-surface-type-mismatch-error.rd +0 -17
- data/doc/en/cairo-surface.rd +0 -72
- data/doc/en/cairo-svg-surface.rd +0 -44
- data/doc/en/cairo-svg-version.rd +0 -24
- data/doc/en/cairo-temp-file-error.rd +0 -17
- data/doc/en/cairo-text-extents.rd +0 -44
- data/doc/en/cairo-win32-printing-surface.rd +0 -27
- data/doc/en/cairo-win32-surface.rd +0 -31
- data/doc/en/cairo-write-error.rd +0 -17
- data/doc/en/cairo.rd +0 -95
- data/doc/en/index.rd +0 -1051
- data/samples/agg/aa_demo.rb +0 -47
@@ -0,0 +1,151 @@
|
|
1
|
+
/* -*- c-file-style: "gnu"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Ruby Cairo Binding
|
4
|
+
*
|
5
|
+
* $Author: kou $
|
6
|
+
* $Date: 2008-08-16 08:16:40 $
|
7
|
+
*
|
8
|
+
* Copyright 2008 Kouhei Sutou <kou@cozmixng.org>
|
9
|
+
*
|
10
|
+
* This file is made available under the same terms as Ruby
|
11
|
+
*
|
12
|
+
*/
|
13
|
+
|
14
|
+
|
15
|
+
#include "rb_cairo.h"
|
16
|
+
#include "rb_cairo_private.h"
|
17
|
+
|
18
|
+
VALUE rb_cCairo_TextCluster = Qnil;
|
19
|
+
|
20
|
+
#if CAIRO_CHECK_VERSION(1, 7, 2)
|
21
|
+
#define _SELF(self) (RVAL2CRTEXTCLUSTER(self))
|
22
|
+
|
23
|
+
cairo_text_cluster_t *
|
24
|
+
rb_cairo_text_cluster_from_ruby_object (VALUE obj)
|
25
|
+
{
|
26
|
+
cairo_text_cluster_t *cluster;
|
27
|
+
if (!rb_cairo__is_kind_of (obj, rb_cCairo_TextCluster))
|
28
|
+
{
|
29
|
+
rb_raise (rb_eTypeError,
|
30
|
+
"not a cairo cluster: %s", rb_cairo__inspect (obj));
|
31
|
+
}
|
32
|
+
Data_Get_Struct (obj, cairo_text_cluster_t, cluster);
|
33
|
+
return cluster;
|
34
|
+
}
|
35
|
+
|
36
|
+
static void
|
37
|
+
cr_text_cluster_free (void *ptr)
|
38
|
+
{
|
39
|
+
if (ptr)
|
40
|
+
{
|
41
|
+
xfree (ptr);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
VALUE
|
46
|
+
rb_cairo_text_cluster_to_ruby_object (cairo_text_cluster_t *cluster)
|
47
|
+
{
|
48
|
+
if (cluster)
|
49
|
+
{
|
50
|
+
cairo_text_cluster_t *new_cluster;
|
51
|
+
|
52
|
+
new_cluster = ALLOC (cairo_text_cluster_t);
|
53
|
+
*new_cluster = *cluster;
|
54
|
+
return Data_Wrap_Struct (rb_cCairo_TextCluster, NULL,
|
55
|
+
cr_text_cluster_free, new_cluster);
|
56
|
+
}
|
57
|
+
else
|
58
|
+
{
|
59
|
+
return Qnil;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
static VALUE
|
64
|
+
cr_text_cluster_allocate (VALUE klass)
|
65
|
+
{
|
66
|
+
return Data_Wrap_Struct (klass, NULL, cr_text_cluster_free, NULL);
|
67
|
+
}
|
68
|
+
|
69
|
+
static VALUE
|
70
|
+
cr_text_cluster_initialize (VALUE self, VALUE num_bytes, VALUE num_glyphs)
|
71
|
+
{
|
72
|
+
cairo_text_cluster_t *cluster;
|
73
|
+
|
74
|
+
cluster = ALLOC (cairo_text_cluster_t);
|
75
|
+
cluster->num_bytes = NUM2INT (num_bytes);
|
76
|
+
cluster->num_glyphs = NUM2INT (num_glyphs);
|
77
|
+
|
78
|
+
DATA_PTR (self) = cluster;
|
79
|
+
return Qnil;
|
80
|
+
}
|
81
|
+
|
82
|
+
static VALUE
|
83
|
+
cr_text_cluster_num_bytes (VALUE self)
|
84
|
+
{
|
85
|
+
return INT2NUM (_SELF(self)->num_bytes);
|
86
|
+
}
|
87
|
+
|
88
|
+
static VALUE
|
89
|
+
cr_text_cluster_num_glyphs (VALUE self)
|
90
|
+
{
|
91
|
+
return INT2NUM (_SELF(self)->num_glyphs);
|
92
|
+
}
|
93
|
+
|
94
|
+
static VALUE
|
95
|
+
cr_text_cluster_set_num_bytes (VALUE self, VALUE num_bytes)
|
96
|
+
{
|
97
|
+
_SELF(self)->num_bytes = NUM2INT (num_bytes);
|
98
|
+
return self;
|
99
|
+
}
|
100
|
+
|
101
|
+
static VALUE
|
102
|
+
cr_text_cluster_set_num_glyphs (VALUE self, VALUE num_glyphs)
|
103
|
+
{
|
104
|
+
_SELF(self)->num_glyphs = NUM2INT (num_glyphs);
|
105
|
+
return self;
|
106
|
+
}
|
107
|
+
|
108
|
+
static VALUE
|
109
|
+
cr_text_cluster_to_s (VALUE self)
|
110
|
+
{
|
111
|
+
VALUE ret;
|
112
|
+
|
113
|
+
ret = rb_str_new2 ("#<");
|
114
|
+
rb_str_cat2 (ret, rb_class2name (CLASS_OF (self)));
|
115
|
+
rb_str_cat2 (ret, ": ");
|
116
|
+
rb_str_cat2 (ret, "num_bytes=");
|
117
|
+
rb_str_concat (ret, rb_inspect (cr_text_cluster_num_bytes (self)));
|
118
|
+
rb_str_cat2 (ret, ", ");
|
119
|
+
rb_str_cat2 (ret, "num_glyphs=");
|
120
|
+
rb_str_concat (ret, rb_inspect (cr_text_cluster_num_glyphs (self)));
|
121
|
+
rb_str_cat2 (ret, ">");
|
122
|
+
|
123
|
+
return ret;
|
124
|
+
}
|
125
|
+
#endif
|
126
|
+
|
127
|
+
void
|
128
|
+
Init_cairo_text_cluster (void)
|
129
|
+
{
|
130
|
+
#if CAIRO_CHECK_VERSION(1, 7, 2)
|
131
|
+
rb_cCairo_TextCluster = rb_define_class_under (rb_mCairo, "TextCluster", rb_cObject);
|
132
|
+
|
133
|
+
rb_define_alloc_func (rb_cCairo_TextCluster, cr_text_cluster_allocate);
|
134
|
+
|
135
|
+
rb_define_method (rb_cCairo_TextCluster, "initialize",
|
136
|
+
cr_text_cluster_initialize, 2);
|
137
|
+
|
138
|
+
rb_define_method (rb_cCairo_TextCluster, "num_bytes",
|
139
|
+
cr_text_cluster_num_bytes, 0);
|
140
|
+
rb_define_method (rb_cCairo_TextCluster, "num_glyphs",
|
141
|
+
cr_text_cluster_num_glyphs, 0);
|
142
|
+
rb_define_method (rb_cCairo_TextCluster, "set_num_bytes",
|
143
|
+
cr_text_cluster_set_num_bytes, 1);
|
144
|
+
rb_define_method (rb_cCairo_TextCluster, "set_num_glyphs",
|
145
|
+
cr_text_cluster_set_num_glyphs, 1);
|
146
|
+
|
147
|
+
rb_define_method (rb_cCairo_TextCluster, "to_s", cr_text_cluster_to_s, 0);
|
148
|
+
|
149
|
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_TextCluster);
|
150
|
+
#endif
|
151
|
+
}
|
data/src/rb_cairo_text_extents.c
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* Ruby Cairo Binding
|
4
4
|
*
|
5
5
|
* $Author: kou $
|
6
|
-
* $Date:
|
6
|
+
* $Date: 2008-08-17 05:41:28 $
|
7
7
|
*
|
8
8
|
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
9
9
|
* Copyright 2004-2005 MenTaLguY <mental@rydia.com>
|
@@ -46,6 +46,29 @@ rb_cairo_text_extents_to_ruby_object (cairo_text_extents_t *extents)
|
|
46
46
|
}
|
47
47
|
}
|
48
48
|
|
49
|
+
static VALUE
|
50
|
+
cr_text_extents_allocate (VALUE klass)
|
51
|
+
{
|
52
|
+
return Data_Wrap_Struct (klass, NULL, -1, NULL);
|
53
|
+
}
|
54
|
+
|
55
|
+
static VALUE
|
56
|
+
cr_text_extents_initialize (VALUE self)
|
57
|
+
{
|
58
|
+
cairo_text_extents_t *extents;
|
59
|
+
|
60
|
+
extents = ALLOC (cairo_text_extents_t);
|
61
|
+
extents->x_bearing = 0.0;
|
62
|
+
extents->y_bearing = -1.0;
|
63
|
+
extents->width = 0.0;
|
64
|
+
extents->height = 1.0;
|
65
|
+
extents->x_advance = 1.0;
|
66
|
+
extents->y_advance = 0.0;
|
67
|
+
|
68
|
+
DATA_PTR (self) = extents;
|
69
|
+
|
70
|
+
return Qnil;
|
71
|
+
}
|
49
72
|
|
50
73
|
static VALUE
|
51
74
|
cr_text_extents_x_bearing (VALUE self)
|
@@ -53,36 +76,78 @@ cr_text_extents_x_bearing (VALUE self)
|
|
53
76
|
return rb_float_new (_SELF(self)->x_bearing);
|
54
77
|
}
|
55
78
|
|
79
|
+
static VALUE
|
80
|
+
cr_text_extents_set_x_bearing (VALUE self, VALUE x_bearing)
|
81
|
+
{
|
82
|
+
_SELF(self)->x_bearing = NUM2DBL (x_bearing);
|
83
|
+
return Qnil;
|
84
|
+
}
|
85
|
+
|
56
86
|
static VALUE
|
57
87
|
cr_text_extents_y_bearing (VALUE self)
|
58
88
|
{
|
59
89
|
return rb_float_new (_SELF(self)->y_bearing);
|
60
90
|
}
|
61
91
|
|
92
|
+
static VALUE
|
93
|
+
cr_text_extents_set_y_bearing (VALUE self, VALUE y_bearing)
|
94
|
+
{
|
95
|
+
_SELF(self)->y_bearing = NUM2DBL (y_bearing);
|
96
|
+
return Qnil;
|
97
|
+
}
|
98
|
+
|
62
99
|
static VALUE
|
63
100
|
cr_text_extents_width (VALUE self)
|
64
101
|
{
|
65
102
|
return rb_float_new (_SELF(self)->width);
|
66
103
|
}
|
67
104
|
|
105
|
+
static VALUE
|
106
|
+
cr_text_extents_set_width (VALUE self, VALUE width)
|
107
|
+
{
|
108
|
+
_SELF(self)->width = NUM2DBL (width);
|
109
|
+
return Qnil;
|
110
|
+
}
|
111
|
+
|
68
112
|
static VALUE
|
69
113
|
cr_text_extents_height (VALUE self)
|
70
114
|
{
|
71
115
|
return rb_float_new (_SELF(self)->height);
|
72
116
|
}
|
73
117
|
|
118
|
+
static VALUE
|
119
|
+
cr_text_extents_set_height (VALUE self, VALUE height)
|
120
|
+
{
|
121
|
+
_SELF(self)->height = NUM2DBL (height);
|
122
|
+
return Qnil;
|
123
|
+
}
|
124
|
+
|
74
125
|
static VALUE
|
75
126
|
cr_text_extents_x_advance (VALUE self)
|
76
127
|
{
|
77
128
|
return rb_float_new (_SELF(self)->x_advance);
|
78
129
|
}
|
79
130
|
|
131
|
+
static VALUE
|
132
|
+
cr_text_extents_set_x_advance (VALUE self, VALUE x_advance)
|
133
|
+
{
|
134
|
+
_SELF(self)->x_advance = NUM2DBL (x_advance);
|
135
|
+
return Qnil;
|
136
|
+
}
|
137
|
+
|
80
138
|
static VALUE
|
81
139
|
cr_text_extents_y_advance (VALUE self)
|
82
140
|
{
|
83
141
|
return rb_float_new (_SELF(self)->y_advance);
|
84
142
|
}
|
85
143
|
|
144
|
+
static VALUE
|
145
|
+
cr_text_extents_set_y_advance (VALUE self, VALUE y_advance)
|
146
|
+
{
|
147
|
+
_SELF(self)->y_advance = NUM2DBL (y_advance);
|
148
|
+
return Qnil;
|
149
|
+
}
|
150
|
+
|
86
151
|
static VALUE
|
87
152
|
cr_text_extents_to_s (VALUE self)
|
88
153
|
{
|
@@ -109,7 +174,7 @@ cr_text_extents_to_s (VALUE self)
|
|
109
174
|
rb_str_cat2 (ret, "y_advance=");
|
110
175
|
rb_str_concat (ret, rb_inspect (cr_text_extents_y_advance (self)));
|
111
176
|
rb_str_cat2 (ret, ">");
|
112
|
-
|
177
|
+
|
113
178
|
return ret;
|
114
179
|
}
|
115
180
|
|
@@ -119,20 +184,38 @@ Init_cairo_text_extents (void)
|
|
119
184
|
{
|
120
185
|
rb_cCairo_TextExtents =
|
121
186
|
rb_define_class_under (rb_mCairo, "TextExtents", rb_cObject);
|
187
|
+
rb_define_alloc_func (rb_cCairo_TextExtents, cr_text_extents_allocate);
|
188
|
+
|
189
|
+
rb_define_method (rb_cCairo_TextExtents, "initialize",
|
190
|
+
cr_text_extents_initialize, 0);
|
122
191
|
|
123
192
|
rb_define_method (rb_cCairo_TextExtents, "x_bearing",
|
124
193
|
cr_text_extents_x_bearing, 0);
|
194
|
+
rb_define_method (rb_cCairo_TextExtents, "set_x_bearing",
|
195
|
+
cr_text_extents_set_x_bearing, 1);
|
125
196
|
rb_define_method (rb_cCairo_TextExtents, "y_bearing",
|
126
197
|
cr_text_extents_y_bearing, 0);
|
198
|
+
rb_define_method (rb_cCairo_TextExtents, "set_y_bearing",
|
199
|
+
cr_text_extents_set_y_bearing, 1);
|
127
200
|
rb_define_method (rb_cCairo_TextExtents, "width",
|
128
201
|
cr_text_extents_width, 0);
|
202
|
+
rb_define_method (rb_cCairo_TextExtents, "set_width",
|
203
|
+
cr_text_extents_set_width, 1);
|
129
204
|
rb_define_method (rb_cCairo_TextExtents, "height",
|
130
205
|
cr_text_extents_height, 0);
|
206
|
+
rb_define_method (rb_cCairo_TextExtents, "set_height",
|
207
|
+
cr_text_extents_set_height, 1);
|
131
208
|
rb_define_method (rb_cCairo_TextExtents, "x_advance",
|
132
209
|
cr_text_extents_x_advance, 0);
|
210
|
+
rb_define_method (rb_cCairo_TextExtents, "set_x_advance",
|
211
|
+
cr_text_extents_set_x_advance, 1);
|
133
212
|
rb_define_method (rb_cCairo_TextExtents, "y_advance",
|
134
213
|
cr_text_extents_y_advance, 0);
|
214
|
+
rb_define_method (rb_cCairo_TextExtents, "set_y_advance",
|
215
|
+
cr_text_extents_set_y_advance, 1);
|
135
216
|
|
136
217
|
rb_define_method (rb_cCairo_TextExtents, "to_s",
|
137
218
|
cr_text_extents_to_s, 0);
|
219
|
+
|
220
|
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_TextExtents);
|
138
221
|
}
|
data/test-unit/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/test/unit/version.rb'
|
6
|
+
|
7
|
+
version = Test::Unit::VERSION
|
8
|
+
ENV["VERSION"] = version
|
9
|
+
Hoe.new('test-unit', version) do |p|
|
10
|
+
p.developer('Kouhei Sutou', 'kou@cozmixng.org')
|
11
|
+
p.developer('Ryan Davis', 'ryand-ruby@zenspider.com')
|
12
|
+
|
13
|
+
# Ex-Parrot:
|
14
|
+
# p.developer('Nathaniel Talbott', 'nathaniel@talbott.ws')
|
15
|
+
end
|
16
|
+
|
17
|
+
task :check_manifest => :clean_test_result
|
18
|
+
|
19
|
+
task :clean_test_result do
|
20
|
+
test_results = Dir.glob("**/.test-result")
|
21
|
+
sh("rm", "-rf", *test_results) unless test_results.empty?
|
22
|
+
end
|
23
|
+
|
24
|
+
task :tag do
|
25
|
+
message = "Released Test::Unit #{version}!"
|
26
|
+
base = "svn+ssh://#{ENV['USER']}@rubyforge.org/var/svn/test-unit/"
|
27
|
+
sh 'svn', 'copy', '-m', message, "#{base}trunk", "#{base}tags/#{version}"
|
28
|
+
end
|
29
|
+
|
30
|
+
# vim: syntax=Ruby
|
@@ -0,0 +1,280 @@
|
|
1
|
+
require 'test/unit/testcase'
|
2
|
+
require 'test/unit/autorunner'
|
3
|
+
|
4
|
+
module Test # :nodoc:
|
5
|
+
#
|
6
|
+
# = Test::Unit - Ruby Unit Testing Framework
|
7
|
+
#
|
8
|
+
# == Introduction
|
9
|
+
#
|
10
|
+
# Unit testing is making waves all over the place, largely due to the
|
11
|
+
# fact that it is a core practice of XP. While XP is great, unit testing
|
12
|
+
# has been around for a long time and has always been a good idea. One
|
13
|
+
# of the keys to good unit testing, though, is not just writing tests,
|
14
|
+
# but having tests. What's the difference? Well, if you just _write_ a
|
15
|
+
# test and throw it away, you have no guarantee that something won't
|
16
|
+
# change later which breaks your code. If, on the other hand, you _have_
|
17
|
+
# tests (obviously you have to write them first), and run them as often
|
18
|
+
# as possible, you slowly build up a wall of things that cannot break
|
19
|
+
# without you immediately knowing about it. This is when unit testing
|
20
|
+
# hits its peak usefulness.
|
21
|
+
#
|
22
|
+
# Enter Test::Unit, a framework for unit testing in Ruby, helping you to
|
23
|
+
# design, debug and evaluate your code by making it easy to write and
|
24
|
+
# have tests for it.
|
25
|
+
#
|
26
|
+
#
|
27
|
+
# == Notes
|
28
|
+
#
|
29
|
+
# Test::Unit has grown out of and superceded Lapidary.
|
30
|
+
#
|
31
|
+
#
|
32
|
+
# == Feedback
|
33
|
+
#
|
34
|
+
# I like (and do my best to practice) XP, so I value early releases,
|
35
|
+
# user feedback, and clean, simple, expressive code. There is always
|
36
|
+
# room for improvement in everything I do, and Test::Unit is no
|
37
|
+
# exception. Please, let me know what you think of Test::Unit as it
|
38
|
+
# stands, and what you'd like to see expanded/changed/improved/etc. If
|
39
|
+
# you find a bug, let me know ASAP; one good way to let me know what the
|
40
|
+
# bug is is to submit a new test that catches it :-) Also, I'd love to
|
41
|
+
# hear about any successes you have with Test::Unit, and any
|
42
|
+
# documentation you might add will be greatly appreciated. My contact
|
43
|
+
# info is below.
|
44
|
+
#
|
45
|
+
#
|
46
|
+
# == Contact Information
|
47
|
+
#
|
48
|
+
# A lot of discussion happens about Ruby in general on the ruby-talk
|
49
|
+
# mailing list (http://www.ruby-lang.org/en/ml.html), and you can ask
|
50
|
+
# any questions you might have there. I monitor the list, as do many
|
51
|
+
# other helpful Rubyists, and you're sure to get a quick answer. Of
|
52
|
+
# course, you're also welcome to email me (Nathaniel Talbott) directly
|
53
|
+
# at mailto:testunit@talbott.ws, and I'll do my best to help you out.
|
54
|
+
#
|
55
|
+
#
|
56
|
+
# == Credits
|
57
|
+
#
|
58
|
+
# I'd like to thank...
|
59
|
+
#
|
60
|
+
# Matz, for a great language!
|
61
|
+
#
|
62
|
+
# Masaki Suketa, for his work on RubyUnit, which filled a vital need in
|
63
|
+
# the Ruby world for a very long time. I'm also grateful for his help in
|
64
|
+
# polishing Test::Unit and getting the RubyUnit compatibility layer
|
65
|
+
# right. His graciousness in allowing Test::Unit to supercede RubyUnit
|
66
|
+
# continues to be a challenge to me to be more willing to defer my own
|
67
|
+
# rights.
|
68
|
+
#
|
69
|
+
# Ken McKinlay, for his interest and work on unit testing, and for his
|
70
|
+
# willingness to dialog about it. He was also a great help in pointing
|
71
|
+
# out some of the holes in the RubyUnit compatibility layer.
|
72
|
+
#
|
73
|
+
# Dave Thomas, for the original idea that led to the extremely simple
|
74
|
+
# "require 'test/unit'", plus his code to improve it even more by
|
75
|
+
# allowing the selection of tests from the command-line. Also, without
|
76
|
+
# RDoc, the documentation for Test::Unit would stink a lot more than it
|
77
|
+
# does now.
|
78
|
+
#
|
79
|
+
# Everyone who's helped out with bug reports, feature ideas,
|
80
|
+
# encouragement to continue, etc. It's a real privilege to be a part of
|
81
|
+
# the Ruby community.
|
82
|
+
#
|
83
|
+
# The guys at RoleModel Software, for putting up with me repeating, "But
|
84
|
+
# this would be so much easier in Ruby!" whenever we're coding in Java.
|
85
|
+
#
|
86
|
+
# My Creator, for giving me life, and giving it more abundantly.
|
87
|
+
#
|
88
|
+
#
|
89
|
+
# == License
|
90
|
+
#
|
91
|
+
# Test::Unit is copyright (c) 2000-2003 Nathaniel Talbott. It is free
|
92
|
+
# software, and is distributed under the Ruby license. See the COPYING
|
93
|
+
# file in the standard Ruby distribution for details.
|
94
|
+
#
|
95
|
+
#
|
96
|
+
# == Warranty
|
97
|
+
#
|
98
|
+
# This software is provided "as is" and without any express or
|
99
|
+
# implied warranties, including, without limitation, the implied
|
100
|
+
# warranties of merchantibility and fitness for a particular
|
101
|
+
# purpose.
|
102
|
+
#
|
103
|
+
#
|
104
|
+
# == Author
|
105
|
+
#
|
106
|
+
# Nathaniel Talbott.
|
107
|
+
# Copyright (c) 2000-2003, Nathaniel Talbott
|
108
|
+
#
|
109
|
+
# ----
|
110
|
+
#
|
111
|
+
# = Usage
|
112
|
+
#
|
113
|
+
# The general idea behind unit testing is that you write a _test_
|
114
|
+
# _method_ that makes certain _assertions_ about your code, working
|
115
|
+
# against a _test_ _fixture_. A bunch of these _test_ _methods_ are
|
116
|
+
# bundled up into a _test_ _suite_ and can be run any time the
|
117
|
+
# developer wants. The results of a run are gathered in a _test_
|
118
|
+
# _result_ and displayed to the user through some UI. So, lets break
|
119
|
+
# this down and see how Test::Unit provides each of these necessary
|
120
|
+
# pieces.
|
121
|
+
#
|
122
|
+
#
|
123
|
+
# == Assertions
|
124
|
+
#
|
125
|
+
# These are the heart of the framework. Think of an assertion as a
|
126
|
+
# statement of expected outcome, i.e. "I assert that x should be equal
|
127
|
+
# to y". If, when the assertion is executed, it turns out to be
|
128
|
+
# correct, nothing happens, and life is good. If, on the other hand,
|
129
|
+
# your assertion turns out to be false, an error is propagated with
|
130
|
+
# pertinent information so that you can go back and make your
|
131
|
+
# assertion succeed, and, once again, life is good. For an explanation
|
132
|
+
# of the current assertions, see Test::Unit::Assertions.
|
133
|
+
#
|
134
|
+
#
|
135
|
+
# == Test Method & Test Fixture
|
136
|
+
#
|
137
|
+
# Obviously, these assertions have to be called within a context that
|
138
|
+
# knows about them and can do something meaningful with their
|
139
|
+
# pass/fail value. Also, it's handy to collect a bunch of related
|
140
|
+
# tests, each test represented by a method, into a common test class
|
141
|
+
# that knows how to run them. The tests will be in a separate class
|
142
|
+
# from the code they're testing for a couple of reasons. First of all,
|
143
|
+
# it allows your code to stay uncluttered with test code, making it
|
144
|
+
# easier to maintain. Second, it allows the tests to be stripped out
|
145
|
+
# for deployment, since they're really there for you, the developer,
|
146
|
+
# and your users don't need them. Third, and most importantly, it
|
147
|
+
# allows you to set up a common test fixture for your tests to run
|
148
|
+
# against.
|
149
|
+
#
|
150
|
+
# What's a test fixture? Well, tests do not live in a vacuum; rather,
|
151
|
+
# they're run against the code they are testing. Often, a collection
|
152
|
+
# of tests will run against a common set of data, also called a
|
153
|
+
# fixture. If they're all bundled into the same test class, they can
|
154
|
+
# all share the setting up and tearing down of that data, eliminating
|
155
|
+
# unnecessary duplication and making it much easier to add related
|
156
|
+
# tests.
|
157
|
+
#
|
158
|
+
# Test::Unit::TestCase wraps up a collection of test methods together
|
159
|
+
# and allows you to easily set up and tear down the same test fixture
|
160
|
+
# for each test. This is done by overriding #setup and/or #teardown,
|
161
|
+
# which will be called before and after each test method that is
|
162
|
+
# run. The TestCase also knows how to collect the results of your
|
163
|
+
# assertions into a Test::Unit::TestResult, which can then be reported
|
164
|
+
# back to you... but I'm getting ahead of myself. To write a test,
|
165
|
+
# follow these steps:
|
166
|
+
#
|
167
|
+
# * Make sure Test::Unit is in your library path.
|
168
|
+
# * require 'test/unit' in your test script.
|
169
|
+
# * Create a class that subclasses Test::Unit::TestCase.
|
170
|
+
# * Add a method that begins with "test" to your class.
|
171
|
+
# * Make assertions in your test method.
|
172
|
+
# * Optionally define #setup and/or #teardown to set up and/or tear
|
173
|
+
# down your common test fixture.
|
174
|
+
# * You can now run your test as you would any other Ruby
|
175
|
+
# script... try it and see!
|
176
|
+
#
|
177
|
+
# A really simple test might look like this (#setup and #teardown are
|
178
|
+
# commented out to indicate that they are completely optional):
|
179
|
+
#
|
180
|
+
# require 'test/unit'
|
181
|
+
#
|
182
|
+
# class TC_MyTest < Test::Unit::TestCase
|
183
|
+
# # def setup
|
184
|
+
# # end
|
185
|
+
#
|
186
|
+
# # def teardown
|
187
|
+
# # end
|
188
|
+
#
|
189
|
+
# def test_fail
|
190
|
+
# assert(false, 'Assertion was false.')
|
191
|
+
# end
|
192
|
+
# end
|
193
|
+
#
|
194
|
+
#
|
195
|
+
# == Test Runners
|
196
|
+
#
|
197
|
+
# So, now you have this great test class, but you still need a way to
|
198
|
+
# run it and view any failures that occur during the run. This is
|
199
|
+
# where Test::Unit::UI::Console::TestRunner (and others, such as
|
200
|
+
# Test::Unit::UI::GTK::TestRunner) comes into play. The console test
|
201
|
+
# runner is automatically invoked for you if you require 'test/unit'
|
202
|
+
# and simply run the file. To use another runner, or to manually
|
203
|
+
# invoke a runner, simply call its run class method and pass in an
|
204
|
+
# object that responds to the suite message with a
|
205
|
+
# Test::Unit::TestSuite. This can be as simple as passing in your
|
206
|
+
# TestCase class (which has a class suite method). It might look
|
207
|
+
# something like this:
|
208
|
+
#
|
209
|
+
# require 'test/unit/ui/console/testrunner'
|
210
|
+
# Test::Unit::UI::Console::TestRunner.run(TC_MyTest)
|
211
|
+
#
|
212
|
+
#
|
213
|
+
# == Test Suite
|
214
|
+
#
|
215
|
+
# As more and more unit tests accumulate for a given project, it
|
216
|
+
# becomes a real drag running them one at a time, and it also
|
217
|
+
# introduces the potential to overlook a failing test because you
|
218
|
+
# forget to run it. Suddenly it becomes very handy that the
|
219
|
+
# TestRunners can take any object that returns a Test::Unit::TestSuite
|
220
|
+
# in response to a suite method. The TestSuite can, in turn, contain
|
221
|
+
# other TestSuites or individual tests (typically created by a
|
222
|
+
# TestCase). In other words, you can easily wrap up a group of
|
223
|
+
# TestCases and TestSuites like this:
|
224
|
+
#
|
225
|
+
# require 'test/unit/testsuite'
|
226
|
+
# require 'tc_myfirsttests'
|
227
|
+
# require 'tc_moretestsbyme'
|
228
|
+
# require 'ts_anothersetoftests'
|
229
|
+
#
|
230
|
+
# class TS_MyTests
|
231
|
+
# def self.suite
|
232
|
+
# suite = Test::Unit::TestSuite.new
|
233
|
+
# suite << TC_MyFirstTests.suite
|
234
|
+
# suite << TC_MoreTestsByMe.suite
|
235
|
+
# suite << TS_AnotherSetOfTests.suite
|
236
|
+
# return suite
|
237
|
+
# end
|
238
|
+
# end
|
239
|
+
# Test::Unit::UI::Console::TestRunner.run(TS_MyTests)
|
240
|
+
#
|
241
|
+
# Now, this is a bit cumbersome, so Test::Unit does a little bit more
|
242
|
+
# for you, by wrapping these up automatically when you require
|
243
|
+
# 'test/unit'. What does this mean? It means you could write the above
|
244
|
+
# test case like this instead:
|
245
|
+
#
|
246
|
+
# require 'test/unit'
|
247
|
+
# require 'tc_myfirsttests'
|
248
|
+
# require 'tc_moretestsbyme'
|
249
|
+
# require 'ts_anothersetoftests'
|
250
|
+
#
|
251
|
+
# Test::Unit is smart enough to find all the test cases existing in
|
252
|
+
# the ObjectSpace and wrap them up into a suite for you. It then runs
|
253
|
+
# the dynamic suite using the console TestRunner.
|
254
|
+
#
|
255
|
+
#
|
256
|
+
# == Questions?
|
257
|
+
#
|
258
|
+
# I'd really like to get feedback from all levels of Ruby
|
259
|
+
# practitioners about typos, grammatical errors, unclear statements,
|
260
|
+
# missing points, etc., in this document (or any other).
|
261
|
+
#
|
262
|
+
|
263
|
+
module Unit
|
264
|
+
# If set to false Test::Unit will not automatically run at exit.
|
265
|
+
def self.run=(flag)
|
266
|
+
@run = flag
|
267
|
+
end
|
268
|
+
|
269
|
+
# Automatically run tests at exit?
|
270
|
+
def self.run?
|
271
|
+
@run ||= false
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
at_exit do
|
277
|
+
unless $! || Test::Unit.run?
|
278
|
+
exit Test::Unit::AutoRunner.run
|
279
|
+
end
|
280
|
+
end
|