跳到主要內容

發表文章

目前顯示的是 2014的文章

Polling with JQuery deferred (en)

Polling with JQuery deferred (en) Problem Objective Ver 0.1 Ver 0.2 (Generalization) Problem Imagine you want to get some web pages via JQuery Ajax, but without knowing how many pages until you actually fetch them. In such case, you can’t aggregate deferred objects before fetching. Available solution is polling pages instead. That is, fetch a page and see if more pages to go. If so, continue to retrieve another one, otherwise stop polling. Let’s assume an API for polling page. e.g. http://example.com/api/page?p=n ` and request it several time with consecutive n . i.e. var api = 'http://example.com/api/page' ; $ . get ( api , { p : 0 }) . then ( function ( data ) { if ( is_more ( data )) { return $ . get ( api , { p : 1 }); } return data ; }) . then (...) ; Now you see the problem I’m gonna shoot it - how to resolve the last then() with polled pages? Objective Prototype: /** * @param api URL f

Automate Unit-test of Web GUI

Automate Unit-test of Web GUI 目標 套件 Application Files Unit-test 單元性測試 ExtJS /unittest.js Jasmine 2.0 /unittest.html /unittest/spec.js /unittest/boot.js 利用 PhantomJS 執行測試 Continuous Integration 持續整合 測試報表 測試涵蓋度報表 測試流程 自動化 Future Work Sandbox for Ext’s Store class 目標 基於 ExtJS MVC 的範例 建立手/自動測試 納入持續整合流程 套件 Jasmine 2.0 (standalone distribution) jasmine-reporters Jenkins JSCover PhantomJS Note 由於 Jasmine 2.0 在 2013 年底才釋出,與 ExtJS 或是 jasmine-reporters 的整合有些細節並不廣為人知(比較難 google 到啦),這篇是以 Jasmine 2.0 為主。 Application Files Root Second Third … MyApp / + ext-4 /<extjs_code> + index.html + app.js + app / + data / + + main.json + + updatemain.json + unittest.js + unittest.html + unittest / + + boot.js + + spec.js + + lib

SQLite 是如何測試的

SQLite 是如何測試的 SQLite 是如何測試的 1.0 介紹 通透且謹慎的測試,是SQLite 的可靠性與強固性的一環。以 3.7.14 版來說,SQLite 函式庫內含近 8.13 萬行的原始碼(不含空白與註解). 相較來說,這個專案對應的測試碼與指令稿高達 1124 倍─相當於 914.211 萬行的程式。 SQLite 是如何測試的 1.0 介紹 1.1 摘要 2.0 自動化測式框架 3.0 異常測試 3.1 記憶體不足(Out-Of-Memory, OOM) 測試 3.2 I/O 錯誤測試 3.3 崩潰測試 3.4 綜合失敗測試 4.0 模糊測試 4.1 模糊 SQL 4.2 崎異資料庫檔案 4.3 邊界值測試 5.0 迴歸測試 6.0 自動資源洩漏偵測 7.0 測試涵蓋度 7.1 語句 v.s. 分支涵蓋度 7.2 防衛性程式碼的涵蓋度測試 7.3 強制涵蓋邊界值與布林向量(布林遮罩)測試 7.5 關於完全涵蓋測試的經驗 8.0 動態分析 8.1 斷言 8.2 Valgrind 8.3 Memsys2 8.4 互斥器斷言 8.5 旅記測試 8.6 有號整數溢位檢驗 9.0 關閉最佳化測試 10.0 靜態分析 11.0 總結 1.1 摘要 三個各自開發的自動化測試框架 倚照佈署設定前提下,百分百的測試涵蓋度 近百萬個測試案例 記憶體不足測試 系統崩潰與跳電測試 模糊測試 邊界值測試 關閉最佳化測試 迴歸測試 崎異(malformed)資料庫測試 大量使用斷言 (assert) 與執行期檢驗 Valgrind (堆積分析工具) 分析 有號數溢位檢驗 2.0 自動化測式框架 有三個獨立開發的自動化測式框架被使用於 SQLite 的核心函式庫。各自被分開來設計、維護,與管理。 TCL 是最早期的測試;他附帶在 SQLite 的原碼樹之中,並使用跟 SQLite 一樣的公開授權。他是在開發 SQLite 的過程中主要的測試工具。TCL 自動化測試框架是以 TCL 指令語言寫成,大約由 2.51 萬行的 C 原碼構成 TCL 介面。這些測試指令碼分布在 711 個檔案中,大小共約 10.0 MB

Notes of Haskell Learning

Notes of Haskell Learning References List Comprehension Function Signature Definition 1. Bindings 2. Guards 3. Expression: let … in … 4. Expression: case … of … Higher Order Functions Map Filter Lambda Fold 1. foldl (fold from left) 2. foldr (fold from right) Function Application: $ Module Load Modules Create Modules Algebraic Data Type Synopsis Abstraction Native Classes Record Type Parameter Constructors Are Functions Partial Specialization A Generic Vector Derived Instance 1. Deriving Eq 2. Deriving Show 3. Deriving Read 4. Deriving Ord Type Synonyms Data Structure 1. List Define Type Class Functor Type Class Invert Pair’s Types References Learn You a Haskell for Great Good! HaskellWiki List Comprehension [( i , j )| i <- [ 0 , 1 ], j <- [ 1. . 6 ] ] -- [( 0 , 1 ),( 0 , 2 ),( 0 , 3 ),( 0 , 4 ),( 0 , 5 ),( 0 , 6 ),( 1 , 1 ),( 1 , 2 ),( 1 , 3 ),( 1 , 4 ),( 1 , 5 ),( 1 , 6 )] Function F