@@ -4,7 +4,10 @@ defmodule KernelTest do
44  use  ExUnit.Case ,  async:  true 
55
66  # Skip these doctests are they emit warnings 
7-   doctest  Kernel ,  except:  [ ===:  2 ,  !==:  2 ,  is_nil:  1 ] 
7+   doctest  Kernel , 
8+     except: 
9+        [ ===:  2 ,  !==:  2 ,  and:  2 ,  or:  2 ]  ++ 
10+         [ is_exception:  1 ,  is_exception:  2 ,  is_nil:  1 ,  is_struct:  1 ,  is_non_struct_map:  1 ] 
811
912  def  id ( arg ) ,  do:  arg 
1013  def  id ( arg1 ,  arg2 ) ,  do:  { arg1 ,  arg2 } 
@@ -298,8 +301,8 @@ defmodule KernelTest do
298301    assert  ( false  and  true )  ==  false 
299302    assert  ( false  and  0 )  ==  false 
300303    assert  ( false  and  raise ( "oops" ) )  ==  false 
301-     assert  ( ( x  =  true )  and  not  x )  ==  false 
302-     assert_raise  BadBooleanError ,  fn  ->  0  and  1  end 
304+     assert  ( ( x  =  Process . get ( :unused ,   true ) )  and  not  x )  ==  false 
305+     assert_raise  BadBooleanError ,  fn  ->  Process . get ( :unused ,   0 )  and  1  end 
303306  end 
304307
305308  test  "or/2"  do 
@@ -310,25 +313,27 @@ defmodule KernelTest do
310313    assert  ( false  or  false )  ==  false 
311314    assert  ( false  or  true )  ==  true 
312315    assert  ( false  or  0 )  ==  0 
313-     assert  ( ( x  =  false )  or  not  x )  ==  true 
314-     assert_raise  BadBooleanError ,  fn  ->  0  or  1  end 
316+     assert  ( ( x  =  Process . get ( :unused ,   false ) )  or  not  x )  ==  true 
317+     assert_raise  BadBooleanError ,  fn  ->  Process . get ( :unused ,   0 )  or  1  end 
315318  end 
316319
317-   defp  struct? ( arg )  when  is_struct ( arg ) ,  do:  true 
318-   defp  struct? ( _arg ) ,  do:  false 
320+   defp  delegate_is_struct ( arg ) ,  do:  is_struct ( arg ) 
321+ 
322+   defp  guarded_is_struct ( arg )  when  is_struct ( arg ) ,  do:  true 
323+   defp  guarded_is_struct ( _arg ) ,  do:  false 
319324
320325  defp  struct_or_map? ( arg )  when  is_struct ( arg )  or  is_map ( arg ) ,  do:  true 
321326  defp  struct_or_map? ( _arg ) ,  do:  false 
322327
323328  test  "is_struct/1"  do 
324-     assert  is_struct ( % { } )  ==  false 
325-     assert  is_struct ( [ ] )  ==  false 
326-     assert  is_struct ( % Macro.Env { } )  ==  true 
327-     assert  is_struct ( % { __struct__:  "foo" } )  ==  false 
328-     assert  struct? ( % Macro.Env { } )  ==  true 
329-     assert  struct? ( % { __struct__:  "foo" } )  ==  false 
330-     assert  struct? ( [ ] )  ==  false 
331-     assert  struct? ( % { } )  ==  false 
329+     assert  delegate_is_struct ( % { } )  ==  false 
330+     assert  delegate_is_struct ( [ ] )  ==  false 
331+     assert  delegate_is_struct ( % Macro.Env { } )  ==  true 
332+     assert  delegate_is_struct ( % { __struct__:  "foo" } )  ==  false 
333+     assert  guarded_is_struct ( % Macro.Env { } )  ==  true 
334+     assert  guarded_is_struct ( % { __struct__:  "foo" } )  ==  false 
335+     assert  guarded_is_struct ( [ ] )  ==  false 
336+     assert  guarded_is_struct ( % { } )  ==  false 
332337  end 
333338
334339  test  "is_struct/1 and other match works"  do 
@@ -337,25 +342,27 @@ defmodule KernelTest do
337342    assert  struct_or_map? ( 10 )  ==  false 
338343  end 
339344
340-   defp  struct? ( arg ,  name )  when  is_struct ( arg ,  name ) ,  do:  true 
341-   defp  struct? ( _arg ,  _name ) ,  do:  false 
345+   defp  delegate_is_struct ( arg ,  name ) ,  do:  is_struct ( arg ,  name ) 
346+ 
347+   defp  guarded_is_struct ( arg ,  name )  when  is_struct ( arg ,  name ) ,  do:  true 
348+   defp  guarded_is_struct ( _arg ,  _name ) ,  do:  false 
342349
343350  defp  struct_or_map? ( arg ,  name )  when  is_struct ( arg ,  name )  or  is_map ( arg ) ,  do:  true 
344351  defp  struct_or_map? ( _arg ,  _name ) ,  do:  false 
345352
346353  defp  not_atom ( ) ,  do:  "not atom" 
347354
348355  test  "is_struct/2"  do 
349-     assert  is_struct ( % { } ,  Macro.Env )  ==  false 
350-     assert  is_struct ( [ ] ,  Macro.Env )  ==  false 
351-     assert  is_struct ( % Macro.Env { } ,  Macro.Env )  ==  true 
352-     assert  is_struct ( % Macro.Env { } ,  URI )  ==  false 
353-     assert  struct? ( % Macro.Env { } ,  Macro.Env )  ==  true 
354-     assert  struct? ( % Macro.Env { } ,  URI )  ==  false 
355-     assert  struct? ( % { __struct__:  "foo" } ,  "foo" )  ==  false 
356-     assert  struct? ( % { __struct__:  "foo" } ,  Macro.Env )  ==  false 
357-     assert  struct? ( [ ] ,  Macro.Env )  ==  false 
358-     assert  struct? ( % { } ,  Macro.Env )  ==  false 
356+     assert  delegate_is_struct ( % { } ,  Macro.Env )  ==  false 
357+     assert  delegate_is_struct ( [ ] ,  Macro.Env )  ==  false 
358+     assert  delegate_is_struct ( % Macro.Env { } ,  Macro.Env )  ==  true 
359+     assert  delegate_is_struct ( % Macro.Env { } ,  URI )  ==  false 
360+     assert  guarded_is_struct ( % Macro.Env { } ,  Macro.Env )  ==  true 
361+     assert  guarded_is_struct ( % Macro.Env { } ,  URI )  ==  false 
362+     assert  guarded_is_struct ( % { __struct__:  "foo" } ,  "foo" )  ==  false 
363+     assert  guarded_is_struct ( % { __struct__:  "foo" } ,  Macro.Env )  ==  false 
364+     assert  guarded_is_struct ( [ ] ,  Macro.Env )  ==  false 
365+     assert  guarded_is_struct ( % { } ,  Macro.Env )  ==  false 
359366
360367    assert_raise  ArgumentError ,  "argument error" ,  fn  -> 
361368      is_struct ( % { } ,  not_atom ( ) ) 
@@ -368,21 +375,23 @@ defmodule KernelTest do
368375    assert  struct_or_map? ( % Macro.Env { } ,  Macro.Env )  ==  true 
369376  end 
370377
371-   defp  non_struct_map? ( arg )  when  is_non_struct_map ( arg ) ,  do:  true 
372-   defp  non_struct_map? ( _arg ) ,  do:  false 
378+   defp  delegate_is_non_struct_map ( arg ) ,  do:  is_non_struct_map ( arg ) 
379+ 
380+   defp  guarded_is_non_struct_map ( arg )  when  is_non_struct_map ( arg ) ,  do:  true 
381+   defp  guarded_is_non_struct_map ( _arg ) ,  do:  false 
373382
374383  defp  non_struct_map_or_struct? ( arg )  when  is_non_struct_map ( arg )  or  is_struct ( arg ) ,  do:  true 
375384  defp  non_struct_map_or_struct? ( _arg ) ,  do:  false 
376385
377386  test  "is_non_struct_map/1"  do 
378-     assert  is_non_struct_map ( % { } )  ==  true 
379-     assert  is_non_struct_map ( [ ] )  ==  false 
380-     assert  is_non_struct_map ( % Macro.Env { } )  ==  false 
381-     assert  is_non_struct_map ( % { __struct__:  "foo" } )  ==  true 
382-     assert  non_struct_map? ( % Macro.Env { } )  ==  false 
383-     assert  non_struct_map? ( % { __struct__:  "foo" } )  ==  true 
384-     assert  non_struct_map? ( [ ] )  ==  false 
385-     assert  non_struct_map? ( % { } )  ==  true 
387+     assert  delegate_is_non_struct_map ( % { } )  ==  true 
388+     assert  delegate_is_non_struct_map ( [ ] )  ==  false 
389+     assert  delegate_is_non_struct_map ( % Macro.Env { } )  ==  false 
390+     assert  delegate_is_non_struct_map ( % { __struct__:  "foo" } )  ==  true 
391+     assert  guarded_is_non_struct_map ( % Macro.Env { } )  ==  false 
392+     assert  guarded_is_non_struct_map ( % { __struct__:  "foo" } )  ==  true 
393+     assert  guarded_is_non_struct_map ( [ ] )  ==  false 
394+     assert  guarded_is_non_struct_map ( % { } )  ==  true 
386395  end 
387396
388397  test  "is_non_struct_map/1 and other match works"  do 
@@ -391,21 +400,23 @@ defmodule KernelTest do
391400    assert  non_struct_map_or_struct? ( 10 )  ==  false 
392401  end 
393402
394-   defp  exception? ( arg )  when  is_exception ( arg ) ,  do:  true 
395-   defp  exception? ( _arg ) ,  do:  false 
403+   defp  delegate_is_exception ( arg ) ,  do:  is_exception ( arg ) 
404+ 
405+   defp  guarded_is_exception ( arg )  when  is_exception ( arg ) ,  do:  true 
406+   defp  guarded_is_exception ( _arg ) ,  do:  false 
396407
397408  defp  exception_or_map? ( arg )  when  is_exception ( arg )  or  is_map ( arg ) ,  do:  true 
398409  defp  exception_or_map? ( _arg ) ,  do:  false 
399410
400411  test  "is_exception/1"  do 
401-     assert  is_exception ( % { } )  ==  false 
402-     assert  is_exception ( [ ] )  ==  false 
403-     assert  is_exception ( % RuntimeError { } )  ==  true 
404-     assert  is_exception ( % { __exception__:  "foo" } )  ==  false 
405-     assert  exception? ( % RuntimeError { } )  ==  true 
406-     assert  exception? ( % { __exception__:  "foo" } )  ==  false 
407-     assert  exception? ( [ ] )  ==  false 
408-     assert  exception? ( % { } )  ==  false 
412+     assert  delegate_is_exception ( % { } )  ==  false 
413+     assert  delegate_is_exception ( [ ] )  ==  false 
414+     assert  delegate_is_exception ( % RuntimeError { } )  ==  true 
415+     assert  delegate_is_exception ( % { __exception__:  "foo" } )  ==  false 
416+     assert  guarded_is_exception ( % RuntimeError { } )  ==  true 
417+     assert  guarded_is_exception ( % { __exception__:  "foo" } )  ==  false 
418+     assert  guarded_is_exception ( [ ] )  ==  false 
419+     assert  guarded_is_exception ( % { } )  ==  false 
409420  end 
410421
411422  test  "is_exception/1 and other match works"  do 
@@ -414,26 +425,28 @@ defmodule KernelTest do
414425    assert  exception_or_map? ( 10 )  ==  false 
415426  end 
416427
417-   defp  exception? ( arg ,  name )  when  is_exception ( arg ,  name ) ,  do:  true 
418-   defp  exception? ( _arg ,  _name ) ,  do:  false 
428+   defp  delegate_is_exception ( arg ,  name ) ,  do:  is_exception ( arg ,  name ) 
429+ 
430+   defp  guarded_is_exception ( arg ,  name )  when  is_exception ( arg ,  name ) ,  do:  true 
431+   defp  guarded_is_exception ( _arg ,  _name ) ,  do:  false 
419432
420433  defp  exception_or_map? ( arg ,  name )  when  is_exception ( arg ,  name )  or  is_map ( arg ) ,  do:  true 
421434  defp  exception_or_map? ( _arg ,  _name ) ,  do:  false 
422435
423436  test  "is_exception/2"  do 
424-     assert  is_exception ( % { } ,  RuntimeError )  ==  false 
425-     assert  is_exception ( [ ] ,  RuntimeError )  ==  false 
426-     assert  is_exception ( % RuntimeError { } ,  RuntimeError )  ==  true 
427-     assert  is_exception ( % RuntimeError { } ,  Macro.Env )  ==  false 
428-     assert  exception? ( % RuntimeError { } ,  RuntimeError )  ==  true 
429-     assert  exception? ( % RuntimeError { } ,  Macro.Env )  ==  false 
430-     assert  exception? ( % { __exception__:  "foo" } ,  "foo" )  ==  false 
431-     assert  exception? ( % { __exception__:  "foo" } ,  RuntimeError )  ==  false 
432-     assert  exception? ( [ ] ,  RuntimeError )  ==  false 
433-     assert  exception? ( % { } ,  RuntimeError )  ==  false 
437+     assert  delegate_is_exception ( % { } ,  RuntimeError )  ==  false 
438+     assert  delegate_is_exception ( [ ] ,  RuntimeError )  ==  false 
439+     assert  delegate_is_exception ( % RuntimeError { } ,  RuntimeError )  ==  true 
440+     assert  delegate_is_exception ( % RuntimeError { } ,  Macro.Env )  ==  false 
441+     assert  guarded_is_exception ( % RuntimeError { } ,  RuntimeError )  ==  true 
442+     assert  guarded_is_exception ( % RuntimeError { } ,  Macro.Env )  ==  false 
443+     assert  guarded_is_exception ( % { __exception__:  "foo" } ,  "foo" )  ==  false 
444+     assert  guarded_is_exception ( % { __exception__:  "foo" } ,  RuntimeError )  ==  false 
445+     assert  guarded_is_exception ( [ ] ,  RuntimeError )  ==  false 
446+     assert  guarded_is_exception ( % { } ,  RuntimeError )  ==  false 
434447
435448    assert_raise  ArgumentError ,  "argument error" ,  fn  -> 
436-       is_exception ( % { } ,  not_atom ( ) ) 
449+       delegate_is_exception ( % { } ,  not_atom ( ) ) 
437450    end 
438451  end 
439452
@@ -954,15 +967,15 @@ defmodule KernelTest do
954967    end 
955968
956969    test  "get_in/1"  do 
957-       users  =  % { "john"  =>  % { age:  27 } ,  :meg  =>  % { age:  23 } } 
970+       users  =  Process . get ( :unused ,   % { "john"  =>  % { age:  27 } ,  :meg  =>  % { age:  23 } } ) 
958971      assert  get_in ( users [ "john" ] [ :age ] )  ==  27 
959972      assert  get_in ( users [ "dave" ] [ :age ] )  ==  nil 
960973      assert  get_in ( users [ "john" ] . age )  ==  27 
961974      assert  get_in ( users [ "dave" ] . age )  ==  nil 
962975      assert  get_in ( users . meg [ :age ] )  ==  23 
963976      assert  get_in ( users . meg . age )  ==  23 
964977
965-       is_nil  =  nil 
978+       is_nil  =  Process . get ( :unused ,   nil ) 
966979      assert  get_in ( is_nil . age )  ==  nil 
967980
968981      assert_raise  KeyError ,  ~r" key :unknown not found"  ,  fn  ->  get_in ( users . unknown )  end 
0 commit comments