@@ -544,101 +544,41 @@ defmodule Kernel.DiagnosticsTest do
544
544
end
545
545
546
546
@ tag :tmp_dir
547
- test "long message ( file) " , % { tmp_dir: tmp_dir } do
548
- path = make_relative_tmp ( tmp_dir , "long-warning .ex" )
547
+ test "IO.warn file+line+column " , % { tmp_dir: tmp_dir } do
548
+ path = make_relative_tmp ( tmp_dir , "io-warn-file-line-column .ex" )
549
549
550
550
source = """
551
- defmodule Sample do
552
- @file "#{ path } "
553
-
554
- def atom_case do
555
- v = "bc"
556
-
557
- case v do
558
- _ when is_atom(v) -> :ok
559
- _ -> :fail
560
- end
561
- end
562
- end
551
+ IO.warn("oops\\ nmulti\\ nline", file: __ENV__.file, line: __ENV__.line, column: 4)
563
552
"""
564
553
565
554
File . write! ( path , source )
566
555
567
556
expected = """
568
- warning: incompatible types:
569
-
570
- binary() !~ atom()
571
-
572
- in expression:
573
-
574
- # #{ path } :8
575
- is_atom(v)
576
-
577
- where "v" was given the type binary() in:
578
-
579
- # #{ path } :5
580
- v = "bc"
581
-
582
- where "v" was given the type atom() in:
583
-
584
- # #{ path } :8
585
- is_atom(v)
586
-
587
- Conflict found at
557
+ warning: oops
558
+ multi
559
+ line
588
560
│
589
- 8 │ _ when is_atom(v) -> :ok
590
- │ ~
561
+ 1 │ IO.warn("oops \\ nmulti \\ nline", file: __ENV__.file, line: __ENV__.line, column: 4)
562
+ │ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~
591
563
│
592
- └─ #{ path } :8:14: Sample.atom_case/0
564
+ └─ tmp\
593
565
"""
594
566
595
- assert capture_eval ( source ) =~ expected
596
- after
597
- purge ( Sample )
567
+ assert capture_io ( :stderr , fn -> Code . eval_file ( path ) end ) =~ expected
598
568
end
599
569
600
- test "long message (nofile)" do
601
- source = """
602
- defmodule Sample do
603
- def atom_case do
604
- v = "bc"
605
-
606
- case v do
607
- _ when is_atom(v) -> :ok
608
- _ -> :fail
609
- end
610
- end
611
- end
612
- """
613
-
614
- expected = """
615
- warning: incompatible types:
616
-
617
- binary() !~ atom()
618
-
619
- in expression:
620
-
621
- # nofile:6
622
- is_atom(v)
570
+ test "IO.warn with missing data" do
571
+ assert capture_eval ( """
572
+ IO.warn("oops-bad", file: #{ inspect ( __ENV__ . file ) } , line: 3, column: nil)
573
+ """ ) =~ "warning: oops-bad"
623
574
624
- where "v" was given the type binary() in:
575
+ assert capture_eval ( """
576
+ IO.warn("oops-bad", file: #{ inspect ( __ENV__ . file ) } , line: nil)
577
+ """ ) =~ "oops-bad"
625
578
626
- # nofile:3
627
- v = "bc"
628
-
629
- where "v" was given the type atom() in:
630
-
631
- # nofile:6
632
- is_atom(v)
633
-
634
- Conflict found at
635
- └─ nofile:6:14: Sample.atom_case/0
636
-
637
- """
638
-
639
- assert capture_eval ( source ) =~ expected
640
- after
641
- purge ( Sample )
579
+ assert capture_eval ( """
580
+ IO.warn("oops-bad", file: nil)
581
+ """ ) =~ "oops-bad"
642
582
end
643
583
644
584
@ tag :tmp_dir
0 commit comments