Add formatter tests (#72)

Closes #24
Builds on #25 by @PrimaryCanary
This commit is contained in:
Radon Rosborough 2022-01-05 15:35:12 -08:00 committed by GitHub
parent 41fa1f70ee
commit 53f243b111
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
68 changed files with 920 additions and 41 deletions

View file

@ -1,35 +0,0 @@
version: 2
shared: &shared
machine:
image: ubuntu-1604:201903-01
steps:
- checkout
# This command will pick up $VERSION from the environment.
- run: >-
make docker
CMD="make -k compile checkdoc longlines"
jobs:
emacs-25:
<<: *shared
environment:
VERSION: "25"
emacs-26:
<<: *shared
environment:
VERSION: "26"
emacs-27:
<<: *shared
environment:
VERSION: "27"
emacs-git:
<<: *shared
environment:
VERSION: "master"
workflows:
version: 2
ci:
jobs:
- emacs-25
- emacs-26
- emacs-27
- emacs-git

23
.github/workflows/formatters.yml vendored Normal file
View file

@ -0,0 +1,23 @@
name: Changed formatters
on: [pull_request]
jobs:
formatters:
runs-on: ubuntu-latest
steps:
- name: Checkout pull request
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Fetch master
run: |
git fetch
- name: Test changed formatters
run: |
set -euo pipefail
mkdir -p .tmp
make docker CMD="make fmt-changed > .tmp/changed"
export FORMATTERS="$(< .tmp/changed)"
if [[ -n "${FORMATTERS}" ]]; then
make fmt-build fmt-docker CMD="make fmt-test"
fi

16
.github/workflows/lint.yml vendored Normal file
View file

@ -0,0 +1,16 @@
name: Lint
on: [push]
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
emacs_version: [25, 26, 27, "master"]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run linters
env:
VERSION: ${{ matrix.emacs_version }}
run: >-
make docker CMD="make lint"

3
.gitignore vendored
View file

@ -1 +1,4 @@
*.elc
.log
.tmp
auto

View file

@ -3,6 +3,8 @@ CMD ?=
EMACS ?= emacs
TAG ?= latest
# The order is important for compilation.
for_compile := *.el
for_checkdoc := *.el
@ -17,7 +19,7 @@ help: ## Show this message
column -t -s'|' >&2
.PHONY: lint
lint: compile checkdoc longlines ## Build project and run all linters
lint: compile checkdoc longlines fmt-lint ## Build project and run all linters
.PHONY: compile
compile: ## Check for byte-compiler errors
@ -52,3 +54,23 @@ clean: ## Remove build artifacts
.PHONY: docker
docker: ## Start a Docker shell; e.g. make docker VERSION=25.3
@scripts/docker.bash "$(VERSION)" "$(CMD)"
.PHONY: fmt-build # env vars: FORMATTERS, TAG
fmt-build: ## Build a Docker image with formatters installed
@test/formatters/build-image.bash
.PHONY: fmt-docker # env var: TAG
fmt-docker: ## Start a Docker shell for testing formatters
@scripts/docker-run.bash -e FORMATTERS "apheleia-formatters:$(TAG)" "$(CMD)"
.PHONY: fmt-lint
fmt-lint: ## Do basic linting for formatter configuration
@test/formatters/run-func.bash apheleia-ft-lint
.PHONY: fmt-check
fmt-changed: ## Get list of changed formatters on this PR
@test/formatters/run-func.bash apheleia-ft-changed
.PHONY: fmt-test # env var: FORMATTERS
fmt-test: ## Actually run formatter tests
@test/formatters/run-func.bash apheleia-ft-test

View file

@ -218,7 +218,32 @@ Apheleia exposes some hooks for advanced customization:
## Contributing
Please see [the contributor guide for my
projects](https://github.com/raxod502/contributor-guide).
projects](https://github.com/raxod502/contributor-guide) for general
information, and the following sections for Apheleia-specific details.
### Adding a formatter
I have done my best to make it straightforward to add a formatter. You
just follow these steps:
1. Install your formatter on your machine so you can test.
2. Create an entry in `apheleia-formatters` with how to run it. (See
the docstring of this variable for explanation about the available
keywords.)
3. Add entries for the relevant major modes in `apheleia-mode-alist`.
4. See if it works for you!
5. Add a file at `test/formatters/installers/yourformatter.bash` which
explains how to install the formatter on Ubuntu. This will be used
by CI.
6. Test with `make fmt-build FORMATTERS=yourformatter` to do the
installation, then `make fmt-docker` to start a shell with the
formatter available. Verify it runs in this environment.
7. Add an example input (pre-formatting) and output (post-formatting)
file at `test/formatters/samplecode/yourformatter/in.whatever` and
`test/formatters/samplecode/yourformatter/out.whatever`.
8. Verify that the tests are passing, using `make fmt-test
FORMATTERS=yourformatter` from inside the `fmt-docker` shell.
9. Submit a pull request, CI should now be passing!
## Acknowledgements

View file

@ -700,10 +700,11 @@ formatter being run, for diagnostic purposes."
(fish-indent . ("fish_indent"))
(gofmt . ("gofmt"))
(google-java-format . ("google-java-format" "-"))
(isort . ("isort" "--stdout" "-"))
(latexindent . ("latexindent"))
(isort . ("isort" "-"))
(latexindent . ("latexindent" "--logfile=/dev/null"))
(mix-format . ("mix" "format" "-"))
(ocamlformat . ("ocamlformat" "-" "--name" filepath))
(ocamlformat . ("ocamlformat" "-" "--name" filepath
"--enable-outside-detected-project"))
(prettier . (npx "prettier" "--stdin-filepath" filepath))
(rustfmt . ("rustfmt" "--quiet" "--emit" "stdout"))
(terraform . ("terraform" "fmt" "-")))

View file

@ -6,6 +6,8 @@ set -o pipefail
find=(
find .
-name .git -prune -o
-name .log -prune -o
-path ./test/formatters -prune -o
-name "*.elc" -o
-type f -print
)

23
scripts/docker-pid1.bash Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail
cat <<"EOF" > /etc/sudoers.d/apheleia
%sudo ALL=(ALL:ALL) NOPASSWD: ALL
EOF
groupadd -g "$(stat -c %g "$PWD")" -o -p '!' -r apheleia
useradd -u "$(stat -c %u "$PWD")" -g "$(stat -c %g "$PWD")" \
-o -p '!' -m -N -l -s /usr/bin/bash -G sudo apheleia
runuser -u apheleia touch /home/apheleia/.sudo_as_admin_successful
if (( "$#" == 0 )) || [[ -z "$1" ]]; then
set -- bash
fi
if (( "$#" == 1 )) && [[ "$1" == *" "* ]]; then
set -- bash -c "$1"
fi
exec runuser -u apheleia -- "$@"

19
scripts/docker-run.bash Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail
repo="$(git rev-parse --show-toplevel)"
docker=(docker)
if [[ "$OSTYPE" != darwin* ]] && [[ "$EUID" != 0 ]]; then
docker=(sudo -E "${docker[@]}")
fi
it=()
if [[ -t 0 ]]; then
it+=(-it)
fi
exec "${docker[@]}" run "${it[@]}" --rm -v "${repo}:/src" \
--entrypoint=/src/scripts/docker-pid1.bash "$@"

View file

@ -22,4 +22,11 @@ docker build . -t "apheleia:$tag" \
--build-arg "UID=$UID" \
--build-arg "VERSION=$tag"
docker run -it --rm -v "$PWD:/home/docker/src" "apheleia:$tag" "${args[@]}"
it=()
if [[ -t 0 ]]; then
it+=(-it)
fi
docker run "${it[@]}" --rm -v "$PWD:/home/docker/src" \
"apheleia:$tag" "${args[@]}"

View file

@ -0,0 +1,13 @@
# Ubuntu 20.04 LTS supported until April 2025
FROM ubuntu:20.04
WORKDIR /build
COPY install-common.bash /build/
RUN ./install-common.bash
ARG FORMATTERS
COPY install-formatters.bash /build/
COPY installers /build/installers/
RUN ./install-formatters.bash
WORKDIR /src

296
test/formatters/apheleia-ft.el Executable file
View file

@ -0,0 +1,296 @@
;; -*- lexical-binding: t -*-
;; `apheleia-ft' - short for `apheleia-formatter-tests'. The functions
;; in here are not part of the public interface of Apheleia and
;; breaking changes may occur at any time.
(require 'apheleia)
(require 'cl-lib)
(require 'map)
(defvar apheleia-ft--test-dir
(file-name-directory
(or load-file-name buffer-file-name))
"Directory containing this module.")
(defun apheleia-ft--get-formatters (&optional all)
"Return list of strings naming the formatters to run.
This is determined by the environment variable FORMATTERS,
defaulting to all known formatters if the environment variable is
not set.
If ALL is non-nil, unconditionally return all formatters."
(let ((env-var (or (getenv "FORMATTERS") "")))
(cond
((or all (string-empty-p env-var))
(mapcar #'symbol-name (map-keys apheleia-formatters)))
(t
(split-string env-var "[ ,]+")))))
(defun apheleia-ft--get-formatters-from-ref (ref)
"Check out given Git REF and return `apheleia-formatters' from there.
Return an Elisp data structure, same as the `apheleia-formatters'
already in memory on the current branch."
(let ((old-apheleia (make-temp-file "apheleia-" nil ".el"))
(stderr-file (make-temp-file "apheleia-ft-stderr-")))
(with-temp-file old-apheleia
(let ((exit-status
(call-process
"git"
nil (list (current-buffer) stderr-file) nil
"show" (format "%s:apheleia.el" ref))))
(unless (zerop exit-status)
(with-temp-buffer
(insert-file-contents stderr-file)
(princ (buffer-string)))
(error "Failed to 'git show %s:apheleia.el', got exit status %S"
ref exit-status))))
(with-temp-buffer
(call-process
(if invocation-directory
(expand-file-name invocation-name invocation-directory)
invocation-name)
nil (current-buffer) nil
"--batch" "-l" old-apheleia "--eval" "(prin1 apheleia-formatters)")
(goto-char (point-min))
(read (current-buffer)))))
(defun apheleia-ft--get-formatters-for-pull-request ()
"Return list of formatter string names that were touched in this PR.
This means their commands in `apheleia-formatters' are different
from how they appear on master, or they were added relative to
master."
(let ((old-formatters (apheleia-ft--get-formatters-from-ref "origin/master"))
(new-formatters apheleia-formatters)
(touched-formatters nil))
(map-do
(lambda (formatter command)
(unless (equal command (alist-get formatter old-formatters))
(push (symbol-name formatter) touched-formatters)))
new-formatters)
touched-formatters))
(defun apheleia-ft-changed ()
"Print to stdout a comma-delimited list of formatters changed in this PR."
(princ (concat
(string-join
(apheleia-ft--get-formatters-for-pull-request) ",")
"\n")))
(defun apheleia-ft--read-file (filename)
"Return the contents of FILENAME as a string."
(with-temp-buffer
(insert-file-contents filename)
(buffer-string)))
(defun apheleia-ft--write-temp-file (contents extension)
"Write file CONTENTS string to temporary file with given EXTENSION.
Return the filename."
(unless (or (string-prefix-p "." extension) (string-empty-p extension))
(setq extension (concat "." extension)))
(make-temp-file "apheleia-ft-file-" nil extension contents))
(defun apheleia-ft--input-files (formatter)
"For given FORMATTER, return list of input files used in test cases.
These are absolute filepaths beginning with \"in.\"."
(directory-files
(apheleia-ft--path-join
apheleia-ft--test-dir
"samplecode" formatter)
'full
"^in\\."))
(defun apheleia-ft--path-join (component &rest components)
"Join COMPONENT and COMPONENTS together, left to right.
Return an absolute path."
(let ((result component))
(while (setq component (pop components))
(setq result (expand-file-name component result)))
result))
(defun apheleia-ft--print-diff (lhs-name lhs rhs-name rhs)
"Print a Git-style line-wise diff between two strings.
LHS-NAME is a human-readable name for the LHS string, same for
RHS-NAME and RHS."
(with-temp-buffer
(let* ((lhs-file (apheleia-ft--write-temp-file lhs lhs-name))
(rhs-file (apheleia-ft--write-temp-file rhs rhs-name))
(stderr-file (make-temp-file "apheleia-ft-stderr-"))
(exit-status
(call-process
"git" nil (list (current-buffer) stderr-file) nil "diff"
"--no-index" lhs-file rhs-file)))
(unless (memq exit-status '(0 1))
(with-temp-buffer
(insert-file-contents stderr-file)
(princ (buffer-string)))
(error "Git diff exited with status %S" exit-status))
(princ (buffer-string)))))
(defun apheleia-ft-lint ()
"Lint general file structure for formatter tests.
This validates that necessary support files exist for every
formatter defined in apheleia.el, and that they are well-formed,
and no extraneous ones exist.
This operation is intended to be fast and simple, and does not
involve running any formatters."
(interactive)
(let ((formatters (mapcar #'symbol-name (map-keys apheleia-formatters)))
(installers
(mapcar
(lambda (filename)
(string-remove-suffix ".bash" filename))
(directory-files
(apheleia-ft--path-join
apheleia-ft--test-dir "installers")
nil "\\.bash$")))
(samplecode-dirs
(directory-files
(apheleia-ft--path-join
apheleia-ft--test-dir "samplecode")
nil "^[^.]")))
(dolist (formatter formatters)
(unless (member formatter installers)
(error "Missing installer script at installers/%s.bash" formatter)))
(dolist (installer installers)
(unless (member installer formatters)
(error "Spurious installer script at installers/%s.bash" installer)))
(dolist (formatter formatters)
(unless (member formatter samplecode-dirs)
(error "Missing sample code dir at samplecode/%s" formatter))
(let ((in-files
(directory-files
(apheleia-ft--path-join
apheleia-ft--test-dir "samplecode" formatter)
nil "^in"))
(out-files nil)
(all-files
(directory-files
(apheleia-ft--path-join
apheleia-ft--test-dir "samplecode" formatter)
nil "^[^.]")))
(unless in-files
(error "Empty sample code dir at samplecode/%s" formatter))
(dolist (in-file in-files)
(let ((out-file (replace-regexp-in-string "^in" "out" in-file)))
(unless (file-exists-p
(apheleia-ft--path-join
apheleia-ft--test-dir "samplecode" formatter out-file))
(error "Input file %s is has no corresponding output file %s"
in-file out-file))
(push out-file out-files)))
(dolist (file all-files)
(unless (or (member file in-files)
(member file out-files))
(error "Spurious sample code file at samplecode/%s/%s"
formatter file)))))
(dolist (samplecode-dir samplecode-dirs)
(unless (member samplecode-dir formatters)
(error
"Spurious sample code directory at samplecode/%s"
samplecode-dir))))
(message "[format-test] linting passed"))
(defun apheleia-ft-test (&rest formatters)
"Run tests for provided FORMATTERS.
Interactively, select a single formatter to test using
`completing-read'. If FORMATTERS is not provided (or,
interactively, with prefix argument), fall back to the FORMATTERS
environment variable, defaulting to all formatters."
(interactive
(unless (or current-prefix-arg noninteractive)
(list (completing-read "Formatter: " (apheleia-ft--get-formatters)))))
(dolist (formatter (or formatters (apheleia-ft--get-formatters)))
(dolist (in-file (apheleia-ft--input-files formatter))
(let ((extension (file-name-extension in-file))
(in-text (apheleia-ft--read-file in-file))
(in-temp-real-file nil)
(in-temp-file nil)
(out-temp-file nil)
(command (alist-get (intern formatter) apheleia-formatters))
(syms nil)
(stdout-buffer nil)
(stderr-file (make-temp-file "apheleia-ft-stderr-"))
(default-directory temporary-file-directory)
(exit-status nil)
(out-file (replace-regexp-in-string
"/in\\([^/]+\\)" "/out\\1" in-file 'fixedcase)))
(mapc
(lambda (arg)
(when (memq arg '(file filepath input output inplace))
(cl-pushnew arg syms)))
command)
(when (or (memq 'file syms) (memq 'filepath syms))
(setq in-temp-real-file (apheleia-ft--write-temp-file
in-text extension)))
(when (or (memq 'input syms) (memq 'inplace syms))
(setq in-temp-file (apheleia-ft--write-temp-file
in-text extension))
(when (memq 'inplace syms)
(setq out-temp-file in-temp-file)))
(when (memq 'output syms)
(setq out-temp-file (apheleia-ft--write-temp-file
"" extension)))
(setq command
(mapcar
(lambda (arg)
(pcase arg
((or `file `filepath)
in-temp-real-file)
((or `input `inplace)
in-temp-file)
(`output
out-temp-file)
(_ arg)))
command))
(setq command (delq 'npx command))
(setq stdout-buffer (get-buffer-create
(format "*apheleia-ft-stdout-%S" formatter)))
(with-current-buffer stdout-buffer
(erase-buffer))
(setq exit-status
(apply
#'call-process
(car command)
(unless (or (memq 'file syms)
(memq 'input syms)
(memq 'inplace syms))
in-file)
(list stdout-buffer stderr-file)
nil
(cdr command)))
;; Verify that formatter succeeded.
(unless (zerop exit-status)
(with-temp-buffer
(insert-file-contents stderr-file)
(princ (buffer-string)))
(error
"Formatter %s exited with status %S" formatter exit-status))
;; Verify that formatter has not touched original file.
(when in-temp-real-file
(let ((in-text-now (apheleia-ft--read-file in-temp-real-file)))
(unless (string= in-text in-text-now)
(apheleia-ft--print-diff
"original" in-text
"updated" in-text-now)
(error "Formatter %s modified original file in place" formatter))))
;; Verify that formatter formatted correctly.
(let ((out-text
(if (or (memq 'output syms) (memq 'inplace syms))
(apheleia-ft--read-file out-temp-file)
(with-current-buffer stdout-buffer
(buffer-string))))
(expected-out-text
(apheleia-ft--read-file out-file)))
(unless (string= out-text expected-out-text)
(apheleia-ft--print-diff
"expected" expected-out-text
"actual" out-text)
(error "Formatter %s did not format as expected" formatter)))
(princ (format
"[format-test] success: formatter %s (file %s)\n"
formatter (file-name-nondirectory in-file)))))))
(provide 'apheleia-ft)

View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail
echo >&2 "build-image.bash: tagging apheleia-formatters:${TAG:-latest}"
if [[ -n "${FORMATTERS:-}" ]]; then
echo "build-image.bash: will install these formatters: ${FORMATTERS}"
else
echo "build-image.bash: will install all formatters by default"
fi
cd "$(dirname "$0")"
docker=(docker)
if [[ "$OSTYPE" != darwin* ]] && [[ "$EUID" != 0 ]]; then
docker=(sudo -E "${docker[@]}")
fi
exec "${docker[@]}" build . \
-t "apheleia-formatters:${TAG:-latest}" \
--build-arg "FORMATTERS=${FORMATTERS:-}"

View file

@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euxo pipefail
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y curl gnupg lsb-release
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
ubuntu_name="$(lsb_release -cs)"
node_repo="$(curl -fsSL https://deb.nodesource.com/setup_current.x | grep NODEREPO= | grep -Eo 'node_[0-9]+\.x' | head -n1)"
tee -a /etc/apt/sources.list.d/nodejs.list >/dev/null <<EOF
deb [arch=amd64] https://deb.nodesource.com/${node_repo} ${ubuntu_name} main
EOF
apt-get update
packages="
bsdmainutils
emacs-nox
git
jq
make
nodejs
sudo
unzip
wget
sudo
unzip
wget
"
apt-get install -y ${packages}
rm /etc/emacs/site-start.d/*
rm -rf /var/lib/apt/lists/*

View file

@ -0,0 +1,44 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ -n "${FORMATTERS:-}" ]]; then
IFS=' ,' read -ra FORMATTERS <<< "${FORMATTERS}"
else
readarray -t FORMATTERS < <(ls installers | grep '\.bash$' | sed 's/\.bash$//')
fi
if (( "${#FORMATTERS[@]}" > 0 )); then
echo >&2 "Installing the following ${#FORMATTERS[@]} formatter(s):"
for f in "${FORMATTERS[@]}"; do
echo >&2 " * ${f}"
done
else
echo >&2 "Installing NO formatters"
fi
echo >&2 "-- Setting up --"
export DEBIAN_FRONTEND=noninteractive
apt-get update
orig_wd="${PWD}"
mkdir /tmp/apheleia-work
cd /tmp/apheleia-work
latest_release() {
curl -fsSL "https://api.github.com/repos/$1/releases/latest" | jq -r .tag_name
}
echo >&2 "-- Will install ${#FORMATTERS[@]} formatter(s) --"
for f in "${FORMATTERS[@]}"; do
echo >&2 "-- Installing formatter ${f} --"
. "${orig_wd}/installers/${f}.bash"
done
echo >&2 "-- Cleaning up --"
rm -rf /var/lib/apt/lists/*
rm -rf /tmp/apheleia-work

View file

@ -0,0 +1 @@
apt-get install -y black

View file

@ -0,0 +1,11 @@
# PPA recommended at https://www.haskell.org/cabal/download.html
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FF3AEACEF6F88286
echo "deb [arch=amd64] http://ppa.launchpad.net/hvr/ghc/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/brittany.list
apt-get update
apt-get install -y cabal-install-3.4 ghc
ln -s /opt/cabal/bin/cabal /usr/local/bin/
cabal v2-update
cabal v2-install brittany
cp -L "$HOME/.cabal/bin/brittany" /usr/local/bin/

View file

@ -0,0 +1 @@
apt-get install -y clang-format

View file

@ -0,0 +1 @@
apt-get install -y fish

View file

@ -0,0 +1 @@
apt-get install -y golang-go

View file

@ -0,0 +1,12 @@
apt-get install -y default-jre
ver="$(latest_release google/google-java-format | sed 's/^v//')"
mkdir /opt/google-java-format
wget "https://github.com/google/google-java-format/releases/download/v${ver}/google-java-format-${ver}-all-deps.jar" -O /opt/google-java-format/google-java-format.jar
cat <<"EOF" > /usr/local/bin/google-java-format
#!/bin/sh
exec java -jar /opt/google-java-format/google-java-format.jar "$@"
EOF
chmod +x /usr/local/bin/google-java-format

View file

@ -0,0 +1 @@
apt-get install -y isort python3-setuptools

View file

@ -0,0 +1 @@
apt-get install -y texlive-extra-utils

View file

@ -0,0 +1 @@
apt-get install -y elixir

View file

@ -0,0 +1,5 @@
apt-get install -y opam
opam init -n --disable-sandboxing --root /opt/ocamlformat
opam install ocamlformat -y --root /opt/ocamlformat
ln -s /opt/ocamlformat/default/bin/ocamlformat /usr/local/bin/

View file

@ -0,0 +1 @@
npm install -g prettier

View file

@ -0,0 +1,5 @@
ver="$(latest_release rust-lang/rustfmt | sed 's/^v//')"
wget "https://github.com/rust-lang/rustfmt/releases/download/v${ver}/rustfmt_linux-x86_64_v${ver}.tar.gz" -O rustfmt.tar.gz
tar -xf rustfmt.tar.gz
cp rustfmt*/rustfmt /usr/local/bin/

View file

@ -0,0 +1,5 @@
curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add -
echo "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" > /etc/apt/sources.list.d/terraform.list
apt-get update
apt-get install -y terraform

8
test/formatters/run-func.bash Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
repo="$(git rev-parse --show-toplevel)"
exec emacs --batch -L "${repo}" -L . -l apheleia-ft -f "$1"

View file

@ -0,0 +1,4 @@
def asdjf ( l,
a):
3
+4

View file

@ -0,0 +1,3 @@
def asdjf(l, a):
3
+4

View file

@ -0,0 +1,10 @@
-- | Foo performs foo and sometimes bar.
foo :: Thoroughness
-> Int -> Int
foo t x = if x > 20
then case t of
Thorough -> x + 50
Somewhat -> x + 20
NotAtAll -> 0
else 10 + 1

View file

@ -0,0 +1,9 @@
-- | Foo performs foo and sometimes bar.
foo :: Thoroughness -> Int -> Int
foo t x = if x > 20
then case t of
Thorough -> x + 50
Somewhat -> x + 20
NotAtAll -> 0
else 10 + 1

View file

@ -0,0 +1,2 @@
// https://www.ioccc.org/2020/burton/prog.c
int main(int b,char**i){long long n=B,a=I^n,r=(a/b&a)>>4,y=atoi(*++i),_=(((a^n/b)*(y>>T)|y>>S)&r)|(a^r);printf("%.8s\n",(char*)&_);}

View file

@ -0,0 +1,6 @@
// https://www.ioccc.org/2020/burton/prog.c
int main(int b, char **i) {
long long n = B, a = I ^ n, r = (a / b & a) >> 4, y = atoi(*++i),
_ = (((a ^ n / b) * (y >> T) | y >> S) & r) | (a ^ r);
printf("%.8s\n", (char *)&_);
}

View file

@ -0,0 +1,10 @@
switch (uname)
case Linux
echo Hi Tux!
case Darwin
echo Hi Hexley!
case FreeBSD NetBSD DragonFly
echo Hi Beastie!
case '*'
echo Hi, stranger!
end

View file

@ -0,0 +1,10 @@
switch (uname)
case Linux
echo Hi Tux!
case Darwin
echo Hi Hexley!
case FreeBSD NetBSD DragonFly
echo Hi Beastie!
case '*'
echo Hi, stranger!
end

View file

@ -0,0 +1,11 @@
package asdfasdf
func
Factorial(x int) int {
if x <=
1 {
return x
}
return x * Factorial(x - 1,
)
}

View file

@ -0,0 +1,9 @@
package asdfasdf
func Factorial(x int) int {
if x <=
1 {
return x
}
return x * Factorial(x-1)
}

View file

@ -0,0 +1,16 @@
package
main
;
public
class
Main { public
static
void main
( String arg[]
){System.out.println
(
"Hello, world"
)
;}}

View file

@ -0,0 +1,7 @@
package main;
public class Main {
public static void main(String arg[]) {
System.out.println("Hello, world");
}
}

View file

@ -0,0 +1,20 @@
from my_lib import Object
import os
from my_lib import Object3
from my_lib import Object2
import sys
from third_party import lib15, lib1, lib2, lib3, lib4, lib5, lib6, lib7, lib8, lib9, lib10, lib11, lib12, lib13, lib14
import sys
from __future__ import absolute_import
from third_party import lib3
print("Hey")
print("yo")

View file

@ -0,0 +1,11 @@
from __future__ import absolute_import
import os
import sys
from my_lib import Object, Object2, Object3
from third_party import (lib1, lib2, lib3, lib4, lib5, lib6, lib7, lib8, lib9,
lib10, lib11, lib12, lib13, lib14, lib15)
print("Hey")
print("yo")

View file

@ -0,0 +1,9 @@
\begin{filecontents}{mybib.bib}
@online{strawberryperl,
title="Strawberry Perl",
url="http://strawberryperl.com/"}
@online{cmhblog,
title="A Perl script ...
url="...
}
\end{filecontents}

View file

@ -0,0 +1,9 @@
\begin{filecontents}{mybib.bib}
@online{strawberryperl,
title="Strawberry Perl",
url="http://strawberryperl.com/"}
@online{cmhblog,
title="A Perl script ...
url="...
}
\end{filecontents}

View file

@ -0,0 +1,7 @@
:c
=
List.last(
[
:a,:b,
:c
])

View file

@ -0,0 +1,6 @@
:c =
List.last([
:a,
:b,
:c
])

View file

@ -0,0 +1,9 @@
(* https://github.com/ocaml-ppx/ocamlformat/blob/main/test/passing/tests/alignment.ml.ref *)
let file_contents = [
]
@ [
foo
] @ [
bar
]

View file

@ -0,0 +1,3 @@
(* https://github.com/ocaml-ppx/ocamlformat/blob/main/test/passing/tests/alignment.ml.ref *)
let file_contents = [] @ [ foo ] @ [ bar ]

View file

@ -0,0 +1,13 @@
body
{
padding-left : 11em;
font-family
: Georgia,
"Times New Roman",
Times, serif;
color: purple;
background-color:
#d8da3d
}

View file

@ -0,0 +1 @@
<h2>Minify <abbr title="HyperText Markup Language">HTML</abbr> and any <abbr title="Cascading Style Sheets">CSS</abbr> or <abbr title="JavaScript">JS</abbr> included in your markup</h2>

View file

@ -0,0 +1,4 @@
function HelloWorld({greeting = "hello", greeted = '"World"', silent = false, onMouseOver,}) {
if(!greeting){return null};
}

View file

@ -0,0 +1 @@
{"arrowParens":"always","bracketSpacing":true,"embeddedLanguageFormatting":"auto","htmlWhitespaceSensitivity":"css","insertPragma":false,"jsxBracketSameLine":false,"jsxSingleQuote":false,"printWidth":80,"proseWrap":"preserve","quoteProps":"as-needed","requirePragma":false,"semi":true,"singleQuote":false,"tabWidth":2,"trailingComma":"es5","useTabs":false,"vueIndentScriptAndStyle":false}

View file

@ -0,0 +1 @@
/* Define standard variables and values for website */$bgcolor: lightblue;$textcolor: darkblue;$fontsize: 18px;/* Use the variables */body{background-color: $bgcolor; color: $textcolor; font-size: $fontsize;}

View file

@ -0,0 +1 @@
interface GreetingSettings{greeting: string; duration?: number; color?: string;}declare function greet(setting: GreetingSettings): void;

View file

@ -0,0 +1,13 @@
---
- hosts:
all
tasks:
- name:
Get software for apt repository management.
apt:
state: present
name:
- python3-pycurl

View file

@ -0,0 +1,6 @@
body {
padding-left: 11em;
font-family: Georgia, "Times New Roman", Times, serif;
color: purple;
background-color: #d8da3d;
}

View file

@ -0,0 +1,5 @@
<h2>
Minify <abbr title="HyperText Markup Language">HTML</abbr> and any
<abbr title="Cascading Style Sheets">CSS</abbr> or
<abbr title="JavaScript">JS</abbr> included in your markup
</h2>

View file

@ -0,0 +1,10 @@
function HelloWorld({
greeting = "hello",
greeted = '"World"',
silent = false,
onMouseOver,
}) {
if (!greeting) {
return null;
}
}

View file

@ -0,0 +1,19 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false
}

View file

@ -0,0 +1,9 @@
/* Define standard variables and values for website */
$bgcolor: lightblue;
$textcolor: darkblue;
$fontsize: 18px; /* Use the variables */
body {
background-color: $bgcolor;
color: $textcolor;
font-size: $fontsize;
}

View file

@ -0,0 +1,6 @@
interface GreetingSettings {
greeting: string;
duration?: number;
color?: string;
}
declare function greet(setting: GreetingSettings): void;

View file

@ -0,0 +1,10 @@
---
- hosts: all
tasks:
- name: Get software for apt repository management.
apt:
state: present
name:
- python3-pycurl

View file

@ -0,0 +1,12 @@
fn foo() {
println!("a");
}
fn bar() {
println!("b");
println!("c");
}

View file

@ -0,0 +1,9 @@
fn foo() {
println!("a");
}
fn bar() {
println!("b");
println!("c");
}

View file

@ -0,0 +1,6 @@
resource "google_sql_user" "user" {
name = "camunda"
instance =google_sql_database_instance.camunda-db.name
password ="futurice"
}

View file

@ -0,0 +1,6 @@
resource "google_sql_user" "user" {
name = "camunda"
instance = google_sql_database_instance.camunda-db.name
password = "futurice"
}