comparison src/of-io-1-fixes.patch @ 6029:fc663bd5f260 release

io package: fix for Java-based BIST in JSON functions * of-io-1-fixes.patch: new file * dist-files.mk: add of-io-1-fixes.patch
author Philip Nienhuis <prnienhuis@users.sf.net>
date Sat, 01 Jan 2022 21:39:48 +0100
parents
children
comparison
equal deleted inserted replaced
6027:7ac6ed5f65d0 6029:fc663bd5f260
1 # HG changeset patch
2 # User Philip Nienhuis <prnienhuis@users.sf.net>
3 # Date 1641061994 -3600
4 # Sat Jan 01 19:33:14 2022 +0100
5 # Node ID 5a3553396bea3eeae23c1f22e6bc21e739fded11
6 # Parent 4ec046f28e6dbd845c2a49693e7f6a8941157ee6
7 fromJSON.m, toJSON.m: improve Java-based BIST (re-apply, bug #60040)
8
9 diff -r 4ec046f28e6d -r 5a3553396bea inst/fromJSON.m
10 --- a/inst/fromJSON.m Thu Dec 30 00:00:41 2021 +0100
11 +++ b/inst/fromJSON.m Sat Jan 01 19:33:14 2022 +0100
12 @@ -875,12 +875,17 @@
13 %! assert(fromJSON('"@@sin"', false), '@@sin');
14 %! assert(fromJSON('"@@(x)3*x"', false),'@@(x)3*x');
15
16 -%!test ## exotic object in structure
17 -%! assert( fromJSON('{"a":"[java.math.BigDecimal]"}'),struct('a','[java.math.BigDecimal]'));
18 +%# exotic object in structure
19 +%!testif HAVE_JAVA
20 +%! if (usejava ("jvm"))
21 +%! assert(fromJSON('{"a":"[java.math.BigDecimal]"}'),struct('a','[java.math.BigDecimal]'));
22 +%! endif
23
24 -%!test ## exotic object (placeholder of class name)
25 -%! assert( fromJSON('"[java.math.BigDecimal]"'),
26 -%! '[java.math.BigDecimal]');
27 +%# exotic object (placeholder of class name)
28 +%!testif HAVE_JAVA
29 +%! if (usejava ("jvm"))
30 +%! assert(fromJSON('"[java.math.BigDecimal]"'),'[java.math.BigDecimal]');
31 +%! endif
32
33 ############### beautified or confusing JSON BIST #####################
34
35 diff -r 4ec046f28e6d -r 5a3553396bea inst/toJSON.m
36 --- a/inst/toJSON.m Thu Dec 30 00:00:41 2021 +0100
37 +++ b/inst/toJSON.m Sat Jan 01 19:33:14 2022 +0100
38 @@ -318,9 +318,13 @@
39 %!test ## string
40 %! assert(toJSON("abcdefg"), '"abcdefg"');
41
42 -%!test ## unknown class
43 -%! obj = javaObject ("java.math.BigDecimal", 1.0);
44 +%# unknown class
45 +%!testif HAVE_JAVA
46 +%! if (usejava ("jvm"))
47 +%! obj = javaObject ("java.math.BigDecimal", 1.0);
48 %! assert(toJSON(obj), '"[java.math.BigDecimal]"');
49 +%! endif
50 +
51
52 %!test ## apparent JSON string, do not quote
53 %! assert(toJSON('[]'),'[]');
54 @@ -453,9 +457,13 @@
55 %! assert(toJSON(@sin),'"@@(x) sin(x)"')
56 %! assert(toJSON(@(a,b)a+b+c),'"@@(a, b) a + b + c"')
57
58 -%!test ## struct with java object
59 -%! obj = javaObject ("java.math.BigDecimal", 1.0);
60 +%# struct with java object
61 +%!testif HAVE_JAVA
62 +%! if (usejava ("jvm"))
63 +%! obj = javaObject ("java.math.BigDecimal", 1.0);
64 %! assert(toJSON(struct('a',obj)), '{"a":"[java.math.BigDecimal]"}');
65 +%! endif
66 +
67
68 %!test ## structure array DEFAULT COMPACT
69 %! s = struct("a",{3.125;3.125});