ensure bad utf-8 is handled, fixes #48

This commit is contained in:
John Bintz 2011-08-04 10:18:05 -04:00
parent 60713fc88f
commit 572d2a8b5a
3 changed files with 7 additions and 1 deletions

2
.gitignore vendored
View File

@ -8,4 +8,4 @@ specrunner.o
ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner
*.o *.o
moc_*.* moc_*.*
.DS_Store

View File

@ -1,4 +1,5 @@
require 'jasmine-core' require 'jasmine-core'
require 'iconv'
module Jasmine module Jasmine
class FilesList class FilesList
@ -14,7 +15,9 @@ module Jasmine
def get_spec_line_numbers(file) def get_spec_line_numbers(file)
line_numbers = {} line_numbers = {}
ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
file.lines.each_with_index.each { |line, index| file.lines.each_with_index.each { |line, index|
line = ic.iconv(line + ' ')[0..-2]
if description = line[%r{(describe|context|it)[( ]*(["'])(.*)\2}, 3] if description = line[%r{(describe|context|it)[( ]*(["'])(.*)\2}, 3]
(line_numbers[description] ||= []) << (index + 1) (line_numbers[description] ||= []) << (index + 1)
end end

View File

@ -1,3 +1,5 @@
# encoding: UTF-8
require 'spec_helper' require 'spec_helper'
require 'jasmine/files_list' require 'jasmine/files_list'
require 'fakefs/spec_helpers' require 'fakefs/spec_helpers'
@ -219,6 +221,7 @@ describe 'test', ->
context 'yes', -> context 'yes', ->
it 'should do something', -> it 'should do something', ->
"yes" "yes"
"PR.registerLangHandler(PR.createSimpleLexer([[\"com\",/^#[^\\n\\r]*/,null,\"#\"],[\"pln\",/^[\\t\\n\\r \\xa0]+/,null,\"\\t\\n\\r \xC2\\xa0\"],[\"str\",/^\"(?:[^\"\\\\]|\\\\[\\S\\s])*(?:\"|$)/,null,'\"']],[[\"kwd\",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\\s/,\n"
SPEC SPEC
end end