JSFiddle - React, Tailwind, and code Playground

by redeyes2015

HTML

<div id=msg></div>
<hr />
<div id=results>
</div>

CSS

#results {
    display: table;
}

#results > div {
    display: table-row;
}

#results > div > div {
    display: table-cell;
    min-width: 5em;
}

JavaScript

var byIF = function(s){
    var i, c;
    for (i = 0; i < s.length; i++) {
        c = s.charAt(i);
        if (!( (c>='@' && c<='Z') || (c>='a' && c<='z') || (c>='0' && c<='9') || c=="!" ||
            c=="$" || c=="%" || c=="-" || c=="." || c=="^" || c=="_" || c=="~")) {
            return false;
        }
    }
    return true;
},
    byIF_2 = function(s){
        var i, c, m;
        for (i = 0, m = s.length; i < m; i++) {
            c = s.charAt(i);
            if (!( (c>='@' && c<='Z') || (c>='a' && c<='z') || (c>='0' && c<='9') || c=="!" ||
                c=="$" || c=="%" || c=="-" || c=="." || c=="^" || c=="_" || c=="~")) {
                return false;
            }
        }
        return true;
    },
    byRegExp = function(s){
        return /^[-@A-Za-z0-9!$%.^_~]+$/.test(s);
    },
    regexp_cache = /^[-@A-Za-z0-9!$%.^_~]+$/,
    byRegExp_cache = function(s){
        return regexp_cache.test(s);
    };

function run_test(name, test_func, str){
    var terminating = false,
        count = 0,
        promise = $.Deferred();
    
    setTimeout(function(){
        $("#results").append(
                "<div><div>"+name+"</div><div>"+count+"</div></div>");
        terminating = true;
        promise.resolve();
        return;
    }, 10000);
    
    var test = function test(){
        if(terminating){
            return;
        }
        var start_ms = new Date().getTime();
        while(true){
            count += 1;
            test_func(str);
            if((new Date().getTime() - start_ms)> 50)
                break;
        }
        setTimeout(test, 0);
    };
    setTimeout(test, 0);
    return promise;
}

var verify = function(tests, str){
    var first_res = tests[0][1](str);
    for(var i = 1, m = tests.length; i<m; ++i){
        if(tests[i][1](str) != first_res){
            alert('boooooo');
        }
    }
};

$(function(){
    var $msg = $('#msg'),
        tests = [ ["if", byIF],
                  ["if_2", byIF_2],
                 ...