ensure bad utf-8 is handled, fixes #48
This commit is contained in:
parent
60713fc88f
commit
572d2a8b5a
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,4 +8,4 @@ specrunner.o
|
||||
ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner
|
||||
*.o
|
||||
moc_*.*
|
||||
|
||||
.DS_Store
|
||||
|
@ -1,4 +1,5 @@
|
||||
require 'jasmine-core'
|
||||
require 'iconv'
|
||||
|
||||
module Jasmine
|
||||
class FilesList
|
||||
@ -14,7 +15,9 @@ module Jasmine
|
||||
def get_spec_line_numbers(file)
|
||||
line_numbers = {}
|
||||
|
||||
ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
|
||||
file.lines.each_with_index.each { |line, index|
|
||||
line = ic.iconv(line + ' ')[0..-2]
|
||||
if description = line[%r{(describe|context|it)[( ]*(["'])(.*)\2}, 3]
|
||||
(line_numbers[description] ||= []) << (index + 1)
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
require 'spec_helper'
|
||||
require 'jasmine/files_list'
|
||||
require 'fakefs/spec_helpers'
|
||||
@ -219,6 +221,7 @@ describe 'test', ->
|
||||
context 'yes', ->
|
||||
it 'should do something', ->
|
||||
"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
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user