ソースを参照

Pulling from upstream

Remove trailing whitespace

Fix test plan for 004-strings.t
pull/10/head
Paul J. Davis 13年前
committed by Dmitry Groshev
コミット
43d2f25a31
17個のファイルの変更91行の追加70行の削除
  1. +7
    -7
      c_src/decoder.c
  2. +10
    -10
      c_src/encoder.c
  3. +2
    -2
      c_src/jiffy.c
  4. +2
    -2
      c_src/jiffy.h
  5. +21
    -5
      c_src/utf8.c
  6. +1
    -1
      c_src/util.c
  7. +1
    -1
      src/jiffy.erl
  8. +2
    -2
      test/001-yajl-tests.t
  9. +4
    -4
      test/002-literals.t
  10. +2
    -2
      test/003-numbers.t
  11. +17
    -12
      test/004-strings.t
  12. +2
    -2
      test/005-arrays.t
  13. +2
    -2
      test/006-maps.t
  14. +2
    -2
      test/007-compound.t
  15. +3
    -3
      test/008-halfword.t
  16. +1
    -1
      test/cases/lonely_minus_sign.json
  17. +12
    -12
      test/etap.erl

+ 7
- 7
c_src/decoder.c ファイルの表示

@ -1,4 +1,4 @@
// This file is part of Jiffy released under the MIT license.
// This file is part of Jiffy released under the MIT license.
// See the LICENSE file for more information. // See the LICENSE file for more information.
#include <assert.h> #include <assert.h>
@ -76,7 +76,7 @@ dec_init(Decoder* d, ErlNifEnv* env, ERL_NIF_TERM arg, ErlNifBinary* bin)
d->st_data = (char*) enif_alloc(STACK_SIZE_INC * sizeof(char)); d->st_data = (char*) enif_alloc(STACK_SIZE_INC * sizeof(char));
d->st_size = STACK_SIZE_INC; d->st_size = STACK_SIZE_INC;
d->st_top = 0; d->st_top = 0;
for(i = 0; i < d->st_size; i++) { for(i = 0; i < d->st_size; i++) {
d->st_data[i] = st_invalid; d->st_data[i] = st_invalid;
} }
@ -122,7 +122,7 @@ dec_push(Decoder* d, char val)
int i; int i;
if(d->st_top >= d->st_size) { if(d->st_top >= d->st_size) {
new_sz = d->st_size + STACK_SIZE_INC;
new_sz = d->st_size + STACK_SIZE_INC;
tmp = (char*) enif_alloc(new_sz * sizeof(char)); tmp = (char*) enif_alloc(new_sz * sizeof(char));
memcpy(tmp, d->st_data, d->st_size * sizeof(char)); memcpy(tmp, d->st_data, d->st_size * sizeof(char));
enif_free(d->st_data); enif_free(d->st_data);
@ -523,7 +523,7 @@ dec_number(Decoder* d, ERL_NIF_TERM* value)
} }
parse: parse:
switch(state) { switch(state) {
case nst_init: case nst_init:
case nst_sign: case nst_sign:
@ -554,7 +554,7 @@ parse:
} }
} }
} }
if(!has_frac && !has_exp) { if(!has_frac && !has_exp) {
num_type = d->atoms->atom_bignum; num_type = d->atoms->atom_bignum;
} else if(has_exp) { } else if(has_exp) {
@ -604,7 +604,7 @@ decode(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{ {
Decoder dec; Decoder dec;
Decoder* d = &dec; Decoder* d = &dec;
ErlNifBinary bin; ErlNifBinary bin;
ERL_NIF_TERM objs = enif_make_list(env, 0); ERL_NIF_TERM objs = enif_make_list(env, 0);
@ -739,7 +739,7 @@ decode(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
curr = enif_make_list_cell(env, val, curr); curr = enif_make_list_cell(env, val, curr);
} }
break; break;
case st_key: case st_key:
switch(d->p[d->i]) { switch(d->p[d->i]) {
case ' ': case ' ':

+ 10
- 10
c_src/encoder.c ファイルの表示

@ -1,4 +1,4 @@
// This file is part of Jiffy released under the MIT license.
// This file is part of Jiffy released under the MIT license.
// See the LICENSE file for more information. // See the LICENSE file for more information.
#include <assert.h> #include <assert.h>
@ -21,7 +21,7 @@ typedef struct {
int iolen; int iolen;
ERL_NIF_TERM iolist; ERL_NIF_TERM iolist;
ErlNifBinary* curr; ErlNifBinary* curr;
char* p; char* p;
unsigned char* u; unsigned char* u;
@ -32,7 +32,7 @@ int
enc_init(Encoder* e, ErlNifEnv* env, ERL_NIF_TERM opts, ErlNifBinary* bin) enc_init(Encoder* e, ErlNifEnv* env, ERL_NIF_TERM opts, ErlNifBinary* bin)
{ {
ERL_NIF_TERM val; ERL_NIF_TERM val;
e->env = env; e->env = env;
e->atoms = enif_priv_data(env); e->atoms = enif_priv_data(env);
e->uescape = 0; e->uescape = 0;
@ -41,7 +41,7 @@ enc_init(Encoder* e, ErlNifEnv* env, ERL_NIF_TERM opts, ErlNifBinary* bin)
if(!enif_is_list(env, opts)) { if(!enif_is_list(env, opts)) {
return 0; return 0;
} }
while(enif_get_list_cell(env, opts, &val, &opts)) { while(enif_get_list_cell(env, opts, &val, &opts)) {
if(enif_compare(val, e->atoms->atom_uescape) == 0) { if(enif_compare(val, e->atoms->atom_uescape) == 0) {
e->uescape = 1; e->uescape = 1;
@ -148,7 +148,7 @@ enc_unknown(Encoder* e, ERL_NIF_TERM value)
e->iolist = enif_make_list_cell(e->env, curr, e->iolist); e->iolist = enif_make_list_cell(e->env, curr, e->iolist);
e->iolen++; e->iolen++;
} }
e->iolist = enif_make_list_cell(e->env, value, e->iolist); e->iolist = enif_make_list_cell(e->env, value, e->iolist);
e->iolen++; e->iolen++;
@ -157,7 +157,7 @@ enc_unknown(Encoder* e, ERL_NIF_TERM value)
if(!enif_alloc_binary(BIN_INC_SIZE, e->curr)) { if(!enif_alloc_binary(BIN_INC_SIZE, e->curr)) {
return 0; return 0;
} }
memset(e->curr->data, 0, e->curr->size); memset(e->curr->data, 0, e->curr->size);
e->p = (char*) e->curr->data; e->p = (char*) e->curr->data;
@ -176,7 +176,7 @@ enc_literal(Encoder* e, const char* literal, size_t len)
memcpy(&(e->p[e->i]), literal, len); memcpy(&(e->p[e->i]), literal, len);
e->i += len; e->i += len;
e->count++;
e->count++;
return 1; return 1;
} }
@ -305,13 +305,13 @@ enc_string(Encoder* e, ERL_NIF_TERM val)
if(uval < 0) { if(uval < 0) {
return 0; return 0;
} }
ulen = unicode_uescape(uval, &(e->p[e->i])); ulen = unicode_uescape(uval, &(e->p[e->i]));
if(ulen < 0) { if(ulen < 0) {
return 0; return 0;
} }
e->i += ulen; e->i += ulen;
ulen = utf8_len(uval); ulen = utf8_len(uval);
if(ulen < 0) { if(ulen < 0) {
return 0; return 0;
@ -434,7 +434,7 @@ encode(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
if(argc != 2) { if(argc != 2) {
return enif_make_badarg(env); return enif_make_badarg(env);
} }
if(!enc_init(e, env, argv[1], &bin)) { if(!enc_init(e, env, argv[1], &bin)) {
return enif_make_badarg(env); return enif_make_badarg(env);
} }

+ 2
- 2
c_src/jiffy.c ファイルの表示

@ -1,4 +1,4 @@
// This file is part of Jiffy released under the MIT license.
// This file is part of Jiffy released under the MIT license.
// See the LICENSE file for more information. // See the LICENSE file for more information.
#include "jiffy.h" #include "jiffy.h"
@ -10,7 +10,7 @@ load(ErlNifEnv* env, void** priv, ERL_NIF_TERM info)
if(st == NULL) { if(st == NULL) {
return 1; return 1;
} }
st->atom_ok = make_atom(env, "ok"); st->atom_ok = make_atom(env, "ok");
st->atom_error = make_atom(env, "error"); st->atom_error = make_atom(env, "error");
st->atom_null = make_atom(env, "null"); st->atom_null = make_atom(env, "null");

+ 2
- 2
c_src/jiffy.h ファイルの表示

@ -1,4 +1,4 @@
// This file is part of Jiffy released under the MIT license.
// This file is part of Jiffy released under the MIT license.
// See the LICENSE file for more information. // See the LICENSE file for more information.
#ifndef JIFFY_H #ifndef JIFFY_H
@ -17,7 +17,7 @@ typedef struct {
ERL_NIF_TERM atom_bigdbl; ERL_NIF_TERM atom_bigdbl;
ERL_NIF_TERM atom_partial; ERL_NIF_TERM atom_partial;
ERL_NIF_TERM atom_uescape; ERL_NIF_TERM atom_uescape;
ERL_NIF_TERM ref_object; ERL_NIF_TERM ref_object;
ERL_NIF_TERM ref_array; ERL_NIF_TERM ref_array;
} jiffy_st; } jiffy_st;

+ 21
- 5
c_src/utf8.c ファイルの表示

@ -1,4 +1,4 @@
// This file is part of Jiffy released under the MIT license.
// This file is part of Jiffy released under the MIT license.
// See the LICENSE file for more information. // See the LICENSE file for more information.
#include "jiffy.h" #include "jiffy.h"
#include <stdio.h> #include <stdio.h>
@ -93,7 +93,7 @@ utf8_validate(unsigned char* data, size_t size)
int ui; int ui;
if((data[0] & 0x80) == 0x00) { if((data[0] & 0x80) == 0x00) {
ulen = 1;
ulen = 1;
} if((data[0] & 0xE0) == 0xC0) { } if((data[0] & 0xE0) == 0xC0) {
ulen = 2; ulen = 2;
} else if((data[0] & 0xF0) == 0xE0) { } else if((data[0] & 0xF0) == 0xE0) {
@ -104,12 +104,12 @@ utf8_validate(unsigned char* data, size_t size)
if(ulen < 0 || ulen > size) { if(ulen < 0 || ulen > size) {
return -1; return -1;
} }
// Check each continuation byte. // Check each continuation byte.
for(ui = 1; ui < ulen; ui++) { for(ui = 1; ui < ulen; ui++) {
if((data[ui] & 0xC0) != 0x80) return -1; if((data[ui] & 0xC0) != 0x80) return -1;
} }
// Wikipedia says I have to check that a UTF-8 encoding // Wikipedia says I have to check that a UTF-8 encoding
// uses as few bits as possible. This means that we // uses as few bits as possible. This means that we
// can't do things like encode 't' in three bytes. // can't do things like encode 't' in three bytes.
@ -120,7 +120,7 @@ utf8_validate(unsigned char* data, size_t size)
// 2: 110xxxxy 10yyyyyy // 2: 110xxxxy 10yyyyyy
// 3: 1110xxxx 10xyyyyy 10yyyyyy // 3: 1110xxxx 10xyyyyy 10yyyyyy
// 4: 11110xxx 10xxyyyy 10yyyyyy 10yyyyyy // 4: 11110xxx 10xxyyyy 10yyyyyy 10yyyyyy
// ulen == 1 passes by definition // ulen == 1 passes by definition
if(ulen == 2) { if(ulen == 2) {
if((data[0] & 0x1E) == 0) if((data[0] & 0x1E) == 0)
@ -132,6 +132,22 @@ utf8_validate(unsigned char* data, size_t size)
if((data[0] & 0x07) + (data[1] & 0x30) == 0) if((data[0] & 0x07) + (data[1] & 0x30) == 0)
return -1; return -1;
} }
// Lastly we need to check some miscellaneous ranges for
// some of the larger code point values.
if(ulen >= 3) {
ui = utf8_to_unicode(data, ulen);
if(ui < 0) {
return -1;
} else if(ui >= 0xD800 && ui <= 0xDFFF) {
return -1;
} else if(ui == 0xFFFE || ui == 0xFFFF) {
return -1;
} else if(ui > 0x10FFFF) {
return -1;
}
}
return ulen; return ulen;
} }

+ 1
- 1
c_src/util.c ファイルの表示

@ -1,4 +1,4 @@
// This file is part of Jiffy released under the MIT license.
// This file is part of Jiffy released under the MIT license.
// See the LICENSE file for more information. // See the LICENSE file for more information.
#include "jiffy.h" #include "jiffy.h"

+ 1
- 1
src/jiffy.erl ファイルの表示

@ -1,4 +1,4 @@
% This file is part of Jiffy released under the MIT license.
% This file is part of Jiffy released under the MIT license.
% See the LICENSE file for more information. % See the LICENSE file for more information.
-module(jiffy). -module(jiffy).

+ 2
- 2
test/001-yajl-tests.t ファイルの表示

@ -1,11 +1,11 @@
#! /usr/bin/env escript #! /usr/bin/env escript
% This file is part of Jiffy released under the MIT license.
% This file is part of Jiffy released under the MIT license.
% See the LICENSE file for more information. % See the LICENSE file for more information.
main([]) -> main([]) ->
code:add_pathz("test"), code:add_pathz("test"),
code:add_pathz("ebin"), code:add_pathz("ebin"),
Cases = read_cases(), Cases = read_cases(),
etap:plan(length(Cases)), etap:plan(length(Cases)),

+ 4
- 4
test/002-literals.t ファイルの表示

@ -1,18 +1,18 @@
#! /usr/bin/env escript #! /usr/bin/env escript
% This file is part of Jiffy released under the MIT license.
% This file is part of Jiffy released under the MIT license.
% See the LICENSE file for more information. % See the LICENSE file for more information.
main([]) -> main([]) ->
code:add_pathz("ebin"), code:add_pathz("ebin"),
code:add_pathz("test"), code:add_pathz("test"),
etap:plan(6), etap:plan(6),
etap:is(jiffy:decode(<<"true">>), true, "DEC: true -> true"), etap:is(jiffy:decode(<<"true">>), true, "DEC: true -> true"),
etap:is(jiffy:encode(true), <<"true">>, "ENC: true -> true"), etap:is(jiffy:encode(true), <<"true">>, "ENC: true -> true"),
etap:is(jiffy:decode(<<"false">>), false, "DEC: false -> false"), etap:is(jiffy:decode(<<"false">>), false, "DEC: false -> false"),
etap:is(jiffy:encode(false), <<"false">>, "ENC: false -> false"), etap:is(jiffy:encode(false), <<"false">>, "ENC: false -> false"),
etap:is(jiffy:decode(<<"null">>), null, "DEC: null -> null"), etap:is(jiffy:decode(<<"null">>), null, "DEC: null -> null"),
etap:is(jiffy:encode(null), <<"null">>, "ENC: null -> null"), etap:is(jiffy:encode(null), <<"null">>, "ENC: null -> null"),

+ 2
- 2
test/003-numbers.t ファイルの表示

@ -1,11 +1,11 @@
#! /usr/bin/env escript #! /usr/bin/env escript
% This file is part of Jiffy released under the MIT license.
% This file is part of Jiffy released under the MIT license.
% See the LICENSE file for more information. % See the LICENSE file for more information.
main([]) -> main([]) ->
code:add_pathz("ebin"), code:add_pathz("ebin"),
code:add_pathz("test"), code:add_pathz("test"),
etap:plan(59), etap:plan(59),
util:test_good(good()), util:test_good(good()),
util:test_errors(errors()), util:test_errors(errors()),

+ 17
- 12
test/004-strings.t ファイルの表示

@ -1,18 +1,18 @@
#! /usr/bin/env escript #! /usr/bin/env escript
% This file is part of Jiffy released under the MIT license.
% This file is part of Jiffy released under the MIT license.
% See the LICENSE file for more information. % See the LICENSE file for more information.
main([]) -> main([]) ->
code:add_pathz("ebin"), code:add_pathz("ebin"),
code:add_pathz("test"), code:add_pathz("test"),
etap:plan(78),
etap:plan(83),
util:test_good(good()), util:test_good(good()),
util:test_good(uescaped(), [uescape]), util:test_good(uescaped(), [uescape]),
util:test_errors(errors()), util:test_errors(errors()),
test_utf8(utf8_cases()), test_utf8(utf8_cases()),
etap:end_tests(). etap:end_tests().
good() -> good() ->
@ -45,6 +45,7 @@ errors() ->
<<"\"", 0, "\"">>, <<"\"", 0, "\"">>,
<<"\"\\g\"">>, <<"\"\\g\"">>,
<<"\"\\uFFFF\"">>, <<"\"\\uFFFF\"">>,
<<"\"\\uFFFE\"">>,
<<"\"\\uD834foo\\uDD1E\"">>, <<"\"\\uD834foo\\uDD1E\"">>,
% CouchDB-345 % CouchDB-345
<<34,78,69,73,77,69,78,32,70,216,82,82,32,70,65,69,78,33,34>> <<34,78,69,73,77,69,78,32,70,216,82,82,32,70,65,69,78,33,34>>
@ -71,13 +72,17 @@ utf8_cases() ->
% Stray continuation byte % Stray continuation byte
<<16#C2, 16#81, 16#80>>, <<16#C2, 16#81, 16#80>>,
<<"foo", 16#80, "bar">>, <<"foo", 16#80, "bar">>,
% Invalid Unicode code points
<<239, 191, 190>>,
<<237, 160, 129>>,
% Not enough extension bytes % Not enough extension bytes
<<16#C0>>, <<16#C0>>,
<<16#E0>>, <<16#E0>>,
<<16#E0, 16#80>>, <<16#E0, 16#80>>,
<<16#F0>>, <<16#F0>>,
<<16#F0, 16#80>>, <<16#F0, 16#80>>,
<<16#F0, 16#80, 16#80>>, <<16#F0, 16#80, 16#80>>,
@ -86,7 +91,7 @@ utf8_cases() ->
<<16#F8, 16#80>>, <<16#F8, 16#80>>,
<<16#F8, 16#80, 16#80>>, <<16#F8, 16#80, 16#80>>,
<<16#F8, 16#80, 16#80, 16#80>>, <<16#F8, 16#80, 16#80, 16#80>>,
<<16#FC>>, <<16#FC>>,
<<16#FC, 16#80>>, <<16#FC, 16#80>>,
<<16#FC, 16#80, 16#80>>, <<16#FC, 16#80, 16#80>>,
@ -96,16 +101,16 @@ utf8_cases() ->
% No data in high bits. % No data in high bits.
<<16#C0, 16#80>>, <<16#C0, 16#80>>,
<<16#C1, 16#80>>, <<16#C1, 16#80>>,
<<16#E0, 16#80, 16#80>>, <<16#E0, 16#80, 16#80>>,
<<16#E0, 16#90, 16#80>>, <<16#E0, 16#90, 16#80>>,
<<16#F0, 16#80, 16#80, 16#80>>, <<16#F0, 16#80, 16#80, 16#80>>,
<<16#F0, 16#88, 16#80, 16#80>>, <<16#F0, 16#88, 16#80, 16#80>>,
<<16#F8, 16#80, 16#80, 16#80, 16#80>>, <<16#F8, 16#80, 16#80, 16#80, 16#80>>,
<<16#F8, 16#84, 16#80, 16#80, 16#80>>, <<16#F8, 16#84, 16#80, 16#80, 16#80>>,
<<16#FC, 16#80, 16#80, 16#80, 16#80, 16#80>>, <<16#FC, 16#80, 16#80, 16#80, 16#80, 16#80>>,
<<16#FC, 16#82, 16#80, 16#80, 16#80, 16#80>> <<16#FC, 16#82, 16#80, 16#80, 16#80, 16#80>>
]. ].

+ 2
- 2
test/005-arrays.t ファイルの表示

@ -1,11 +1,11 @@
#! /usr/bin/env escript #! /usr/bin/env escript
% This file is part of Jiffy released under the MIT license.
% This file is part of Jiffy released under the MIT license.
% See the LICENSE file for more information. % See the LICENSE file for more information.
main([]) -> main([]) ->
code:add_pathz("ebin"), code:add_pathz("ebin"),
code:add_pathz("test"), code:add_pathz("test"),
etap:plan(18), etap:plan(18),
util:test_good(good()), util:test_good(good()),
util:test_errors(errors()), util:test_errors(errors()),

+ 2
- 2
test/006-maps.t ファイルの表示

@ -1,11 +1,11 @@
#! /usr/bin/env escript #! /usr/bin/env escript
% This file is part of Jiffy released under the MIT license.
% This file is part of Jiffy released under the MIT license.
% See the LICENSE file for more information. % See the LICENSE file for more information.
main([]) -> main([]) ->
code:add_pathz("ebin"), code:add_pathz("ebin"),
code:add_pathz("test"), code:add_pathz("test"),
etap:plan(15), etap:plan(15),
util:test_good(good()), util:test_good(good()),
util:test_errors(errors()), util:test_errors(errors()),

+ 2
- 2
test/007-compound.t ファイルの表示

@ -1,11 +1,11 @@
#! /usr/bin/env escript #! /usr/bin/env escript
% This file is part of Jiffy released under the MIT license.
% This file is part of Jiffy released under the MIT license.
% See the LICENSE file for more information. % See the LICENSE file for more information.
main([]) -> main([]) ->
code:add_pathz("ebin"), code:add_pathz("ebin"),
code:add_pathz("test"), code:add_pathz("test"),
etap:plan(12), etap:plan(12),
util:test_good(good()), util:test_good(good()),
util:test_errors(errors()), util:test_errors(errors()),

+ 3
- 3
test/008-halfword.t ファイルの表示

@ -1,13 +1,13 @@
#! /usr/bin/env escript #! /usr/bin/env escript
% This file is part of Jiffy released under the MIT license.
% This file is part of Jiffy released under the MIT license.
% See the LICENSE file for more information. % See the LICENSE file for more information.
main([]) -> main([]) ->
code:add_pathz("ebin"), code:add_pathz("ebin"),
code:add_pathz("test"), code:add_pathz("test"),
etap:plan(unknown), etap:plan(unknown),
etap:is(jiffy:decode(<<"1">>) =:= 1, true, "1 =:= 1"), etap:is(jiffy:decode(<<"1">>) =:= 1, true, "1 =:= 1"),
etap:is(jiffy:decode(<<"1">>) == 1, true, "1 == 1"), etap:is(jiffy:decode(<<"1">>) == 1, true, "1 == 1"),

+ 1
- 1
test/cases/lonely_minus_sign.json ファイルの表示

@ -2,6 +2,6 @@
"foo", true, "foo", true,
true, "blue", true, "blue",
"baby where are you?", "oh boo hoo!", "baby where are you?", "oh boo hoo!",
-
-
] ]

+ 12
- 12
test/etap.erl ファイルの表示

@ -1,5 +1,5 @@
%% Copyright (c) 2008-2009 Nick Gerakines <nick@gerakines.net> %% Copyright (c) 2008-2009 Nick Gerakines <nick@gerakines.net>
%%
%%
%% Permission is hereby granted, free of charge, to any person %% Permission is hereby granted, free of charge, to any person
%% obtaining a copy of this software and associated documentation %% obtaining a copy of this software and associated documentation
%% files (the "Software"), to deal in the Software without %% files (the "Software"), to deal in the Software without
@ -8,10 +8,10 @@
%% copies of the Software, and to permit persons to whom the %% copies of the Software, and to permit persons to whom the
%% Software is furnished to do so, subject to the following %% Software is furnished to do so, subject to the following
%% conditions: %% conditions:
%%
%%
%% The above copyright notice and this permission notice shall be %% The above copyright notice and this permission notice shall be
%% included in all copies or substantial portions of the Software. %% included in all copies or substantial portions of the Software.
%%
%%
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
%% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES %% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
%% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND %% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@ -20,7 +20,7 @@
%% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING %% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
%% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR %% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
%% OTHER DEALINGS IN THE SOFTWARE. %% OTHER DEALINGS IN THE SOFTWARE.
%%
%%
%% @author Nick Gerakines <nick@gerakines.net> [http://socklabs.com/] %% @author Nick Gerakines <nick@gerakines.net> [http://socklabs.com/]
%% @author Jeremy Wall <jeremy@marzhillstudios.com> %% @author Jeremy Wall <jeremy@marzhillstudios.com>
%% @version 0.3.4 %% @version 0.3.4
@ -32,14 +32,14 @@
%% @todo Explain in documentation why we use a process to handle test input. %% @todo Explain in documentation why we use a process to handle test input.
%% @doc etap is a TAP testing module for Erlang components and applications. %% @doc etap is a TAP testing module for Erlang components and applications.
%% This module allows developers to test their software using the TAP method. %% This module allows developers to test their software using the TAP method.
%%
%%
%% <blockquote cite="http://en.wikipedia.org/wiki/Test_Anything_Protocol"><p> %% <blockquote cite="http://en.wikipedia.org/wiki/Test_Anything_Protocol"><p>
%% TAP, the Test Anything Protocol, is a simple text-based interface between %% TAP, the Test Anything Protocol, is a simple text-based interface between
%% testing modules in a test harness. TAP started life as part of the test %% testing modules in a test harness. TAP started life as part of the test
%% harness for Perl but now has implementations in C/C++, Python, PHP, Perl %% harness for Perl but now has implementations in C/C++, Python, PHP, Perl
%% and probably others by the time you read this. %% and probably others by the time you read this.
%% </p></blockquote> %% </p></blockquote>
%%
%%
%% The testing process begins by defining a plan using etap:plan/1, running %% The testing process begins by defining a plan using etap:plan/1, running
%% a number of etap tests and then calling eta:end_tests/0. Please refer to %% a number of etap tests and then calling eta:end_tests/0. Please refer to
%% the Erlang modules in the t directory of this project for example tests. %% the Erlang modules in the t directory of this project for example tests.
@ -335,7 +335,7 @@ skip(TestFun, Reason) when is_function(TestFun), is_list(Reason) ->
ok. ok.
%% @spec skip(Q, TestFun, Reason) -> ok %% @spec skip(Q, TestFun, Reason) -> ok
%% Q = true | false | function()
%% Q = true | false | function()
%% TestFun = function() %% TestFun = function()
%% Reason = string() %% Reason = string()
%% @doc Skips a test conditionally. The first argument to this function can %% @doc Skips a test conditionally. The first argument to this function can
@ -551,7 +551,7 @@ test_server(State) ->
count = State#test_state.count + 1, count = State#test_state.count + 1,
pass = State#test_state.pass + 1 pass = State#test_state.pass + 1
}; };
{_From, fail, Desc} -> {_From, fail, Desc} ->
FullMessage = skip_diag( FullMessage = skip_diag(
" - " ++ Desc, " - " ++ Desc,
@ -587,11 +587,11 @@ mk_tap(Result, Desc) ->
case [IsSkip, Result] of case [IsSkip, Result] of
[_, true] -> [_, true] ->
etap_server ! {self(), pass, Desc}, etap_server ! {self(), pass, Desc},
true;
[1, _] ->
true;
[1, _] ->
etap_server ! {self(), pass, Desc}, etap_server ! {self(), pass, Desc},
true;
_ ->
true;
_ ->
etap_server ! {self(), fail, Desc}, etap_server ! {self(), fail, Desc},
false false
end. end.

読み込み中…
キャンセル
保存