|
61 | 61 | @test repr(mime, x, context=IOContext(stdout, :error_digits=>error_digits, :compact=>true)) == "x_val\\pmx_err"
|
62 | 62 | end
|
63 | 63 | end
|
| 64 | + |
| 65 | + @variables y_val, y_err |
| 66 | + y = measurement(y_val, y_err) |
| 67 | + c = complex(x, y) |
| 68 | + |
| 69 | + @test_throws ErrorException repr(c, context=:error_digits=>-4) |
| 70 | + @test repr(c) == "(x_val ± x_err) + (y_val ± y_err)im" |
| 71 | + @test repr(c, context=:compact=>true) == "(x_val±x_err)+(y_val±y_err)im" |
| 72 | + for error_digits in (0, 7) |
| 73 | + @test repr(c, context=:error_digits=>error_digits) == "(x_val ± x_err) + (y_val ± y_err)im" |
| 74 | + @test repr(c, context=IOContext(stdout, :error_digits=>error_digits, :compact=>true)) == "(x_val±x_err)+(y_val±y_err)im" |
| 75 | + end |
| 76 | + |
| 77 | + @test repr("text/plain", c) == "(x_val ± x_err) + (y_val ± y_err)im" |
| 78 | + @test repr("text/plain", c, context=:compact=>true) == "(x_val±x_err)+(y_val±y_err)im" |
| 79 | + for error_digits in (0, 7) |
| 80 | + @test repr("text/plain", c, context=:error_digits=>error_digits) == "(x_val ± x_err) + (y_val ± y_err)im" |
| 81 | + @test repr("text/plain", c, context=IOContext(stdout, :error_digits=>error_digits, :compact=>true)) == "(x_val±x_err)+(y_val±y_err)im" |
| 82 | + end |
| 83 | + |
| 84 | + @test repr("text/latex", c) == "\$(x_val \\pm x_err) + (y_val \\pm y_err)im\$" |
| 85 | + @test repr("text/latex", c, context=:compact=>true) == "\$(x_val\\pmx_err)+(y_val\\pmy_err)im\$" |
| 86 | + for error_digits in (0, 7) |
| 87 | + @test repr("text/latex", c, context=:error_digits=>error_digits) == "\$(x_val \\pm x_err) + (y_val \\pm y_err)im\$" |
| 88 | + @test repr("text/latex", c, context=IOContext(stdout, :error_digits=>error_digits, :compact=>true)) == "\$(x_val\\pmx_err)+(y_val\\pmy_err)im\$" |
| 89 | + end |
| 90 | + |
| 91 | + for mime in ("text/x-tex", "text/x-latex") |
| 92 | + @test repr(mime, c) == "(x_val \\pm x_err) + (y_val \\pm y_err)im" |
| 93 | + @test repr(mime, c, context=:compact=>true) == "(x_val\\pmx_err)+(y_val\\pmy_err)im" |
| 94 | + for error_digits in (0, 7) |
| 95 | + @test repr(mime, c, context=:error_digits=>error_digits) == "(x_val \\pm x_err) + (y_val \\pm y_err)im" |
| 96 | + @test repr(mime, c, context=IOContext(stdout, :error_digits=>error_digits, :compact=>true)) == "(x_val\\pmx_err)+(y_val\\pmy_err)im" |
| 97 | + end |
| 98 | + end |
64 | 99 | end
|
65 | 100 |
|
66 | 101 | ##### Mathematical Operations
|
|
0 commit comments