-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: should be done per language, not test case
- Loading branch information
Reinaldy Rafli
committed
Aug 8, 2021
1 parent
122d78c
commit 91e59f4
Showing
24 changed files
with
368 additions
and
5,243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { test } from 'uvu'; | ||
import * as assert from 'uvu/assert'; | ||
import detectLang from '../src/index'; | ||
|
||
test('hello world', () => { | ||
assert.equal('C', detectLang('printf("Hello world!\\n");')); | ||
}); | ||
|
||
test('fizz buzz', () => { | ||
assert.equal( | ||
'C', | ||
detectLang(`#include <stdio.h> | ||
int main(void) | ||
{ | ||
int i; | ||
for (i = 1; i <= 100; ++i) | ||
{ | ||
if (i % 3 == 0) | ||
printf("Fizz"); | ||
if (i % 5 == 0) | ||
printf("Buzz"); | ||
if ((i % 3 != 0) && (i % 5 != 0)) | ||
printf("%d", i); | ||
printf("\n"); | ||
} | ||
return 0; | ||
}`), | ||
); | ||
}); | ||
|
||
test('variable declaration', () => { | ||
assert.equal('C', detectLang('int *ptr;')); | ||
}); | ||
|
||
test('file', () => { | ||
assert.equal( | ||
'C', | ||
detectLang(`static int IndexEntry__set_mtime__meth(lua_State *L) { | ||
IndexEntry * this_idx1 = obj_type_IndexEntry_check(L,1); | ||
git_time_t secs_idx2 = luaL_checkinteger(L,2); | ||
unsigned int nanosecs_idx3 = luaL_checkinteger(L,3); | ||
this_idx1->mtime.seconds = secs_idx2; | ||
this_idx1->mtime.nanoseconds = nanosecs_idx3; | ||
return 0; | ||
}`), | ||
); | ||
}); | ||
|
||
test.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { test } from 'uvu'; | ||
import * as assert from 'uvu/assert'; | ||
import detectLang from '../src/index'; | ||
|
||
test('hello world', () => { | ||
assert.equal('C++', detectLang('cout << "Hello world" << endl;')); | ||
}); | ||
|
||
test('fizz buzz', () => { | ||
assert.equal( | ||
'C++', | ||
detectLang(`/* | ||
* fizzbuzz.cpp | ||
* | ||
* Created on: Apr 25, 2012 | ||
* Author: Brian Geffon | ||
* | ||
* fizzbuzz solved without looping or conditionals using only template recursion. | ||
*/ | ||
#include <iostream> | ||
#include <string> | ||
template <int r> struct FizzBuzzPrinter { | ||
static const int fizzBuzzed = 0; | ||
template <typename T> FizzBuzzPrinter(T t) {} | ||
}; | ||
template <> struct FizzBuzzPrinter<0> { | ||
static const int fizzBuzzed = 1; | ||
template <typename T> FizzBuzzPrinter(T t) { | ||
std::cout << t; | ||
} | ||
}; | ||
template <int N> struct FizzBuzz: FizzBuzz<N - 1> { | ||
FizzBuzz() { | ||
FizzBuzzPrinter<(N % 15)>("FizzBuzz"); | ||
FizzBuzzPrinter<(N % 5) + FizzBuzzPrinter<N % 15>::fizzBuzzed>("Buzz"); | ||
FizzBuzzPrinter<(N % 3) + FizzBuzzPrinter<(N % 15)>::fizzBuzzed + FizzBuzzPrinter<(N % 5) + FizzBuzzPrinter<N % 15>::fizzBuzzed>::fizzBuzzed>("Fizz"); | ||
FizzBuzzPrinter<FizzBuzzPrinter<N % 3>::fizzBuzzed + FizzBuzzPrinter<N % 5>::fizzBuzzed>(int(N)); | ||
std::cout << std::endl; | ||
} | ||
}; | ||
template <> struct FizzBuzz<0> {}; | ||
int main (int argc, char **argv) | ||
{ | ||
FizzBuzz<100> p; | ||
return 0; | ||
}`), | ||
); | ||
}); | ||
|
||
test.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { test } from 'uvu'; | ||
import * as assert from 'uvu/assert'; | ||
import detectLang from '../src/index'; | ||
|
||
test('hello world', () => { | ||
assert.equal('CSS', detectLang('.hello-world {\n\tfont-size: 100px;\n}')); | ||
}); | ||
|
||
test('long', () => { | ||
assert.equal( | ||
'CSS', | ||
detectLang(`/** | ||
* Improve readability when focused and also mouse hovered in all browsers. | ||
*/ | ||
a:active, | ||
a:hover { | ||
outline: 0; | ||
} | ||
/** | ||
* Address styling not present in IE 8/9/10/11, Safari, and Chrome. | ||
*/ | ||
abbr[title] { | ||
border-bottom: 1px dotted; | ||
}`), | ||
); | ||
}); | ||
|
||
test.run(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.