Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7920

Show
Ignore:
Timestamp:
10/15/07 17:19:16 (11 months ago)
Author:
tobie
Message:

prototype: Make sure $w always returns an array.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/prototype/trunk/CHANGELOG

    r7877 r7920  
    11*SVN* 
     2 
     3* Make sure $w always returns an array. [Andrew Dupont, Tobie Langel] 
    24 
    35* Add more tests to Hash. [Mislav Marohnić] 
  • spinoffs/prototype/trunk/src/array.js

    r7876 r7920  
    129129 
    130130function $w(string) { 
     131  if (!Object.isString(string)) return []; 
    131132  string = string.strip(); 
    132133  return string ? string.split(/\s+/) : []; 
  • spinoffs/prototype/trunk/test/unit/array.html

    r7193 r7920  
    205205      assertEnumEqual(['a', 'b', 'c', 'd'], $w('a b c d')); 
    206206      assertEnumEqual([], $w(' ')); 
     207      assertEnumEqual([], $w('')); 
     208      assertEnumEqual([], $w(null)); 
     209      assertEnumEqual([], $w(undefined)); 
     210      assertEnumEqual([], $w()); 
     211      assertEnumEqual([], $w(10)); 
    207212      assertEnumEqual(['a'], $w('a')); 
    208213      assertEnumEqual(['a'], $w('a '));