Differences between revisions 3 and 5 (spanning 2 versions)
Revision 3 as of 2006-03-24 03:10:01
Size: 3606
Editor: wolfg
Comment:
Revision 5 as of 2006-03-24 03:36:29
Size: 4693
Editor: wolfg
Comment:
Deletions are marked like this. Additions are marked like this.
Line 17: Line 17:
 * 这个程序可以 <!> 从 ^在例子目录下的^ py/roman/stage1/ --(的 examples)-- 目录中 <!> 获得 ^找到^ 。  * 这个程序可以 <!> 从 ^在例子目录下的^ py/roman/stage2/ --(的 examples)-- 目录中 <!> 获得 ^找到^ 。
Line 41: Line 41:
 *  * <!> 这有个大新闻 ^好消息来了^ :这个版本的 toRoman 函数能够通过 已知值测试。 记住,这并不能证明完全没问题,但至少 <!> 已经通过了大量的测试 ^通过测试多种有效输入考验了这个函数^:包括 <!> 生成^每个^单一 <!> 罗马数字字符^字符的罗马数字^, <!> 最大可能^可能的最大^输入(3999),以及 <!> ^可能的^最长的罗马数字表示(3888 对应的) 。从这点来看,你--(可以)--有理由 <!> 自信的人为 ^相信^这个函数对于任何有效输入 <!> ^都^不会出问题。
 * {i} put sth. through his paces. 考查某人[某物]的本领[性能], 考验某人[某物]是否合用. 固定用法。
Line 45: Line 46:
 *  * 但是,函数对无效输入仍然不 “起作用”,每个 无效输入测试 都失败。 这 <!> 可以 ^很好^理解 ,你还没有对无效输入进行检查 <!> ,^。 <!> ^独立测试 (!) 测试用例 (!) 希望捕捉到特定的异常(通过 assertRaises),而你根本没有让这些异常引发。 这是你下一 <!> 步^阶段^的工作。

2006-03-24 校对记要

TableOfContents

校对文件: roman.xml

章节: [http://www.woodpecker.org.cn/obp/diveintopython-zh-5.4/zh-cn/dist/htmlflat/diveintopython.html#roman1.5 第14章]

第14章第2节 roman.py, 第2阶段

[http://www.woodpecker.org.cn/obp/diveintopython-zh-5.4/zh-cn/dist/htmlflat/diveintopython.html#roman.stage2]


第3行

  • This file is available in py/roman/stage2/ in the examples directory.
  • 这个程序可以 <!>在例子目录下的 py/roman/stage2/ 的 examples 目录中 <!> 获得 找到


Example 14.3 的注释1第1句

  • romanNumeralMap is a tuple of tuples which defines three things:
  • romanNumeralMap 是一个 <!> 用来定义三个内容的元组的元组 元组的元组,定义了三方面的内容


Example 14.3 的注释1第1点

  • 1.The character representations of the most basic Roman numerals. Note that this is not just the single-character Roman numerals; you're also defining two-character pairs like CM (“one hundred less than one thousand”); this will make the toRoman code simpler later.
  • 1. <!> 代表大部分罗马数字 <!> 字符。 注意不只是 <!> 罗马数字的单字符 单字符的罗马数字,你同样在这里定义诸如 CM (“ <!> 比一千少一百 表示900”)的双字符,这可以 <!>稍后编写的 toRoman 简单一些。


Example 14.3 的注释1第2点

  • Here's where your rich data structure pays off, because you don't need any special logic to handle the subtraction rule.
  • 这里便显示出你丰富的数据结构带来的优势,你不 <!> 必处理 需要什么特定的逻辑 <!> 处理减法规则。


Example 14.5.

  • Example 14.5. Output of romantest2.py against roman2.py
  • <!>romantest2.py 测试 roman2.py 的 <!> 输出 结果


Example 14.5.输出的注释1

  • toRoman does, in fact, always return uppercase, because romanNumeralMap defines the Roman numeral representations as uppercase. So this test passes already.
  • <!> toRoman 通过,事实上所有返回值都是大写的 事实上toRoman 的返回值总是大写的,因为 romanNumeralMap 定义的罗马字符都是以大写字母表示的。 因此这个测试已经通过了。


Example 14.5.输出的注释2

  • Here's the big news: this version of the toRoman function passes the known values test. Remember, it's not comprehensive, but it does put the function through its paces with a variety of good inputs, including inputs that produce every single-character Roman numeral, the largest possible input (3999), and the input that produces the longest possible Roman numeral (3888). At this point, you can be reasonably confident that the function works for any good input value you could throw at it.
  • <!> 这有个大新闻 好消息来了 :这个版本的 toRoman 函数能够通过 已知值测试。 记住,这并不能证明完全没问题,但至少 <!> 已经通过了大量的测试 通过测试多种有效输入考验了这个函数:包括 <!> 生成每个单一 <!> 罗马数字字符字符的罗马数字<!> 最大可能可能的最大输入(3999),以及 <!> 可能的最长的罗马数字表示(3888 对应的) 。从这点来看,你可以有理由 <!> 自信的人为 相信这个函数对于任何有效输入 <!> 不会出问题。

  • {i} put sth. through his paces. 考查某人[某物]的本领[性能], 考验某人[某物]是否合用. 固定用法。


Example 14.5.输出的注释3

  • However, the function does not “work” for bad values; it fails every single bad input test. That makes sense, because you didn't include any checks for bad input. Those test cases look for specific exceptions to be raised (via assertRaises), and you're never raising them. You'll do that in the next stage.
  • 但是,函数对无效输入仍然不 “起作用”,每个 无效输入测试 都失败。 这 <!> 可以 很好理解 ,你还没有对无效输入进行检查 <!>。 <!> 独立测试 (!) 测试用例 (!) 希望捕捉到特定的异常(通过 assertRaises),而你根本没有让这些异常引发。 这是你下一 <!>阶段的工作。


最后一句

  • Here's the rest of the output of the unit test, listing the details of all the failures. You're down to 10.
  • <!>下面是单元测试结果的剩余部分,列出了所有的失败 <!>的详细信息。你已经让它降到了10个 <!>

  • {i} 句尾少了一个句号 :)


DiveIntoPythonZh/2006-03-24 (last edited 2009-12-25 07:13:55 by localhost)