Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
ensure bad utf-8 is handled, fixes #48
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbintz committed Aug 4, 2011
1 parent 60713fc commit 572d2a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ specrunner.o
ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner
*.o
moc_*.*

.DS_Store
3 changes: 3 additions & 0 deletions lib/jasmine/files_list.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'jasmine-core'
require 'iconv'

module Jasmine
class FilesList
Expand All @@ -14,7 +15,9 @@ class << self
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
Expand Down
3 changes: 3 additions & 0 deletions spec/lib/jasmine/files_list_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# encoding: UTF-8

require 'spec_helper'
require 'jasmine/files_list'
require 'fakefs/spec_helpers'
Expand Down Expand Up @@ -219,6 +221,7 @@
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

Expand Down

0 comments on commit 572d2a8

Please sign in to comment.