gEDA-user: [PATCH 1/3] Quick testcase for patch #3071482.

2011-01-02 Thread Patrick Bernaud

---

 tests/testcase.sch |  128 
 tests/testcase.scm |   41 +
 2 files changed, 169 insertions(+), 0 deletions(-)
 create mode 100644 tests/testcase.sch
 create mode 100644 tests/testcase.scm

diff --git a/tests/testcase.sch b/tests/testcase.sch
new file mode 100644
index 000..b8165ff
--- /dev/null
+++ b/tests/testcase.sch
@@ -0,0 +1,128 @@
+v 20100214 2
+C 4 4 0 0 0 title-bordered-A3.sym
+T 41500 48900 9 30 1 0 0 0 1
+Test file for gnetlist:get-package-attribute, patch #3071482
+T 46400 48200 8 10 1 0 0 0 1
+Do not change the order of the elements in the file.
+C 46700 46800 1 0 0 resistor-1.sym
+{
+T 47000 47200 5 10 0 0 0 0 1
+device=RESISTOR
+T 46900 47100 5 10 1 1 0 0 1
+refdes=R1
+T 46900 46600 5 10 1 1 0 0 1
+value=OK
+}
+C 48000 46800 1 0 0 resistor-1.sym
+{
+T 48300 47200 5 10 0 0 0 0 1
+device=RESISTOR
+T 48200 47100 5 10 1 1 0 0 1
+refdes=R2
+}
+C 48000 46100 1 0 0 resistor-1.sym
+{
+T 48300 46500 5 10 0 0 0 0 1
+device=RESISTOR
+T 48200 46400 5 10 1 1 0 0 1
+refdes=R2
+}
+C 49300 46800 1 0 0 resistor-1.sym
+{
+T 49600 47200 5 10 0 0 0 0 1
+device=RESISTOR
+T 49500 47100 5 10 1 1 0 0 1
+refdes=R3
+T 49500 46600 5 10 1 1 0 0 1
+value=OK
+}
+C 49300 46100 1 0 0 resistor-1.sym
+{
+T 49600 46500 5 10 0 0 0 0 1
+device=RESISTOR
+T 49500 46400 5 10 1 1 0 0 1
+refdes=R3
+T 49500 45900 5 10 1 1 0 0 1
+value=OK
+}
+C 50600 46800 1 0 0 resistor-1.sym
+{
+T 50900 47200 5 10 0 0 0 0 1
+device=RESISTOR
+T 50800 47100 5 10 1 1 0 0 1
+refdes=R4
+T 50800 46600 5 10 1 1 0 0 1
+value=value1
+}
+C 50600 46100 1 0 0 resistor-1.sym
+{
+T 50900 46500 5 10 0 0 0 0 1
+device=RESISTOR
+T 50800 46400 5 10 1 1 0 0 1
+refdes=R4
+T 50800 45900 5 10 1 1 0 0 1
+value=value2
+}
+C 50600 45400 1 0 0 resistor-1.sym
+{
+T 50900 45800 5 10 0 0 0 0 1
+device=RESISTOR
+T 50800 45700 5 10 1 1 0 0 1
+refdes=R4
+T 50800 45200 5 10 1 1 0 0 1
+value=value3
+}
+C 51900 46800 1 0 0 resistor-1.sym
+{
+T 52200 47200 5 10 0 0 0 0 1
+device=RESISTOR
+T 52100 47100 5 10 1 1 0 0 1
+refdes=R5
+}
+C 51900 46100 1 0 0 resistor-1.sym
+{
+T 52200 46500 5 10 0 0 0 0 1
+device=RESISTOR
+T 52100 46400 5 10 1 1 0 0 1
+refdes=R5
+}
+C 51900 45400 1 0 0 resistor-1.sym
+{
+T 52200 45800 5 10 0 0 0 0 1
+device=RESISTOR
+T 52100 45700 5 10 1 1 0 0 1
+refdes=R5
+T 52100 45200 5 10 1 1 0 0 1
+value=OK
+}
+T 43600 44200 9 10 1 0 0 0 3
+multiple instances
+same value
+expected result: OK
+T 43600 43300 9 10 1 0 0 0 3
+multiple instances
+different values
+expected result: value1 with warning
+T 43600 42400 9 10 1 0 0 0 3
+multiple instances
+one instance (not first) with attribute
+expected result: unknown with warning
+T 43600 45100 9 10 1 0 0 0 3
+multiple instances
+no attributes
+expected result: unknown
+T 43600 46000 9 10 1 0 0 0 2
+single instance
+expected result: OK
+L 45400 46200 47100 46200 3 0 0 0 -1 -1
+L 47100 46500 47100 46200 3 0 0 0 -1 -1
+L 45900 45400 48400 45400 3 0 0 0 -1 -1
+L 48400 46000 48400 45400 3 0 0 0 -1 -1
+L 45500 44500 49700 44500 3 0 0 0 -1 -1
+L 49700 45800 49700 44500 3 0 0 0 -1 -1
+L 45500 43600 51100 43600 3 0 0 0 -1 -1
+L 51100 45100 51100 43600 3 0 0 0 -1 -1
+L 52300 45100 52300 42700 3 0 0 0 -1 -1
+L 52300 42700 46800 42700 3 0 0 0 -1 -1
+T 43000 46600 9 10 1 0 0 0 1
+WITH DEFAULT RESOLVER,
diff --git a/tests/testcase.scm b/tests/testcase.scm
new file mode 100644
index 000..2be7205
--- /dev/null
+++ b/tests/testcase.scm
@@ -0,0 +1,41 @@
+(use-modules (ice-9 format))
+
+(define-macro (expect form expected)
+  `(begin
+ (let ((result ,form))
+   (if (equal? result ,expected)
+   (format #t OK~%)
+   (format #t ~%ERROR: evaluating ~s produced: ~a instead of: ~a~%
+   ',form result ,expected)
+
+(display attribute from non-existent package... )
+(expect (gnetlist:get-package-attribute R0 value) unknown)
+(newline)
+
+(display unknown attribute from single symbol package... )
+(expect (gnetlist:get-package-attribute R1 foo) unknown)
+(newline)
+
+(display existing attribute from single symbol package... )
+(expect (gnetlist:get-package-attribute R1 value) OK)
+(newline)
+
+(display attribute value from multi symbol package:\n)
+(display \tno symbol instances with this attribute... )
+(expect (gnetlist:get-package-attribute R2 value) unknown)
+
+(display \tall symbol instances with same attribute value... )
+(expect (gnetlist:get-package-attribute R3 value) OK)
+
+(display \tdifferent attribute value for each symbol instance... )
+;; current behavior, take value from first symbol in file order
+;; should also test for warning
+(expect (gnetlist:get-package-attribute R4 value) value1)
+
+(display \tcustom attribute value resolver... )
+(define (attribute-value-resolver refdes name values)
+  ;; select first existing attribute from symbols in the file order
+  (or (find string? values) unknown))
+(expect (gnetlist:get-package-attribute R5 value) OK)
+
+;(quit)




Re: gEDA-user: [PATCH 1/3] Quick testcase for patch #3071482.

2011-01-02 Thread Peter TB Brett
On Sunday 02 January 2011 17:19:23 Patrick Bernaud wrote:

 [snip]

  2 files changed, 169 insertions(+), 0 deletions(-)
  create mode 100644 tests/testcase.sch
  create mode 100644 tests/testcase.scm
 
 diff --git a/tests/testcase.sch b/tests/testcase.sch

 [snip]


Hi Patrick,

Where exactly is this patch supposed to be applied...?  Or is it purely for 
informational purposes?

Thanks,

   Peter

-- 
Peter Brett pe...@peter-b.co.uk
Remote Sensing Research Group
Surrey Space Centre


signature.asc
Description: This is a digitally signed message part.


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user