#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
これは足し算をするだけの関数 add() を定義し、
その動作確認を doctest を通して行う例題です。
テストしない場合には「python add.py」で実行。
テストしたい場合には「python add.py -v」で実行。

参考: http://docs.python.jp/3.4/library/doctest.html
"""

def add(a, b):
    """
    >>> a = 1; b = 2
    >>> add(a,b)
    3
    >>> add(2,5)
    7
    >>> add("hoge",1)
    Traceback (most recent call last):
    ...
    ValueError: inputs a and b must be integer
    """
    if (isinstance(a, int) == False) or (isinstance(b, int) == False):
        raise ValueError("inputs a and b must be integer")
    return a + b

if __name__ == "__main__":
    import doctest
    doctest.testmod()

