@@ -11,8 +11,43 @@ function Base.show(io::IO, mime::MIME"text/plain", foo::Foo)
11
11
print (io, " ()" )
12
12
end
13
13
14
- @test endswith (string (Foo ()), " test_jive_sprints.Foo()" )
15
- @test sprint_plain (Foo ()) == " Foo()"
16
- @test sprint_colored (Foo ()) == " \e [92mFoo\e [39m()"
14
+ foo = Foo ()
15
+ @test endswith (string (foo), " test_jive_sprints.Foo()" )
16
+ @test endswith (sprint (show, foo), " test_jive_sprints.Foo()" )
17
+ @test sprint_plain (foo) == " Foo()"
18
+ @test sprint_colored (foo) == " \e [92mFoo\e [39m()"
19
+
20
+ @test " π" == string (pi ) ==
21
+ sprint (show, pi )
22
+ @test " π = 3.1415926535897..." == sprint_plain (pi ) ==
23
+ sprint_colored (pi )
24
+ for x in (pi , [1 2 3 ],
25
+ :, sprint, Base. show)
26
+ @test string (x) == sprint (show, x) != sprint_plain (x) == sprint_colored (x)
27
+ end
28
+
29
+ for x in (:foo , " foo" )
30
+ @test string (x) != sprint (show, x) == sprint_plain (x) == sprint_colored (x)
31
+ end
32
+
33
+ for x in (Foo,
34
+ nothing , true , 1 : 3 , 1 : 2 : 3 ,
35
+ Int64, String, Tuple{}, Union{Int}, T where T,
36
+ (), (1 , 2 , 3 ),
37
+ (;), (; a = 1 ),
38
+ [],
39
+ )
40
+ @test string (x) == sprint (show, x) == sprint_plain (x) == sprint_colored (x)
41
+ end
42
+
43
+ if VERSION >= v " 1.8"
44
+ array2 = eval (Meta. parse (""" [;;]""" )) # [;;]
45
+ array3 = eval (Meta. parse (""" [;;;]""" )) # [;;;]
46
+ for x in (array2, array3)
47
+ @test string (x) == sprint (show, x) != sprint_plain (x) == sprint_colored (x)
48
+ end
49
+ x = eval (Meta. parse (""" [;]""" )) # [;]
50
+ @test string (x) == sprint (show, x) == sprint_plain (x) == sprint_colored (x)
51
+ end
17
52
18
53
end # module test_jive_sprints
0 commit comments