{
 "metadata":{},
 "nbformat":4,
 "nbformat_minor":4,
 "cells":[
  {
   "cell_type":"markdown",
   "metadata":{
    "editable":true
   },
   "source":[
    "<!-- jupyter-book 02_21_testdoc.ipynb -->\n",
    "# User-defined environments\n",
    "\n",
    "The example in the section [Example 1: A test function](02_21_testdoc.html#ex:test:1p1) demonstrates how to write a test function.\n",
    "That is, a special test function for a function `add` appears in\n",
    "the example in the section [Example 1: A test function](02_21_testdoc.html#ex:test:1p1).\n",
    "\n",
    "## Example 1: A test function\n",
    "<div id=\"ex:test:1p1\"></div>\n",
    "\n",
    "Suppose we want to write a test function for checking the\n",
    "implementation of a Python function for addition."
   ]
  },
  {
   "cell_type":"code",
   "execution_count":8,
   "metadata":{
    "collapsed":false,
    "editable":true
   },
   "outputs":[],
   "source":[
    "def add(a, b):\n",
    "    return a + b\n",
    "\n",
    "def test_add():\n",
    "    a = 1; b = 1\n",
    "    expected = a + b\n",
    "    computed = add(a, b)\n",
    "    assert expected == computed"
   ]
  },
  {
   "cell_type":"markdown",
   "metadata":{
    "editable":true
   },
   "source":[
    "## Example 2: Addition\n",
    "<div id=\"ex:math:1p1\"></div>\n",
    "\n",
    "We have"
   ]
  },
  {
   "cell_type":"markdown",
   "metadata":{
    "editable":true
   },
   "source":[
    "$$\n",
    "1 + 1 = 2\n",
    "$$"
   ]
  },
  {
   "cell_type":"markdown",
   "metadata":{
    "editable":true
   },
   "source":[
    "or in tabular form:\n",
    "\n",
    "<table class=\"table\" border=\"1\">\n",
    "<thead>\n",
    "<tr><th align=\"center\">Problem</th> <th align=\"center\">Result</th> </tr>\n",
    "</thead>\n",
    "<tbody>\n",
    "<tr><td align=\"center\">   $1+1$      </td> <td align=\"center\">   $2$       </td> </tr>\n",
    "</tbody>\n",
    "</table>\n",
    "\n",
    "**Highlight box!**\n",
    "\n",
    "This environment is used to highlight something:"
   ]
  },
  {
   "cell_type":"markdown",
   "metadata":{
    "editable":true
   },
   "source":[
    "$$\n",
    "E = mc^2\n",
    "$$"
   ]
  }
 ]
}